Skip to content
Permalink
Browse files

fix(eslint-plugin): [no-extra-non-null-assertion] false positive with…

… non-nullable computed key (#2737)
  • Loading branch information
ddubrava committed Nov 5, 2020
1 parent c8a4dad commit e82698c0ec796e460e40c3dd90a30bd100db05c2
@@ -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,
};
},
@@ -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: [
{

0 comments on commit e82698c

Please sign in to comment.
You can’t perform that action at this time.