File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ export default util.createRule({
32
32
33
33
return {
34
34
'TSNonNullExpression > TSNonNullExpression' : checkExtraNonNullAssertion ,
35
- 'MemberExpression[optional = true] > TSNonNullExpression' : checkExtraNonNullAssertion ,
35
+ 'MemberExpression[optional = true] > TSNonNullExpression.object ' : checkExtraNonNullAssertion ,
36
36
'CallExpression[optional = true] > TSNonNullExpression.callee' : checkExtraNonNullAssertion ,
37
37
} ;
38
38
} ,
Original file line number Diff line number Diff line change @@ -33,6 +33,15 @@ function foo(bar?: { n: number }) {
33
33
checksCounter?.textContent!.trim();
34
34
` ,
35
35
} ,
36
+ // https://github.com/typescript-eslint/typescript-eslint/issues/2732
37
+ {
38
+ code : `
39
+ function foo(key: string | null) {
40
+ const obj = {};
41
+ return obj?.[key!];
42
+ }
43
+ ` ,
44
+ } ,
36
45
] ,
37
46
invalid : [
38
47
{
You can’t perform that action at this time.
0 commit comments