Skip to content

Commit

Permalink
fix(eslint-plugin): [no-extra-non-null-assertion] false positive with…
Browse files Browse the repository at this point in the history
… non-nullable computed key (#2737)
  • Loading branch information
ddubrava committed Nov 5, 2020
1 parent c8a4dad commit e82698c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Expand Up @@ -32,7 +32,7 @@ export default util.createRule({

return {
'TSNonNullExpression > TSNonNullExpression': checkExtraNonNullAssertion,
'MemberExpression[optional = true] > TSNonNullExpression': checkExtraNonNullAssertion,
'MemberExpression[optional = true] > TSNonNullExpression.object': checkExtraNonNullAssertion,
'CallExpression[optional = true] > TSNonNullExpression.callee': checkExtraNonNullAssertion,
};
},
Expand Down
Expand Up @@ -33,6 +33,15 @@ function foo(bar?: { n: number }) {
checksCounter?.textContent!.trim();
`,
},
// https://github.com/typescript-eslint/typescript-eslint/issues/2732
{
code: `
function foo(key: string | null) {
const obj = {};
return obj?.[key!];
}
`,
},
],
invalid: [
{
Expand Down

0 comments on commit e82698c

Please sign in to comment.