Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(eslint-plugin): [no-extra-non-null-assertion] false positive with non-nullable computed key #2737

Conversation

@ddubrava
Copy link
Contributor

@ddubrava ddubrava commented Nov 4, 2020

Fixes #2732

function foo(key: string | null) {
  const obj = {};
  return obj?.[key!];
}

function foo(key: string | null) {
  const obj = {};
  return obj?.[a!?.key!];
}

function foo(key: string | null) {
  const obj = {};
  return obj!?.[key!];
}

Some extra code tests that were used in AST to check the solution

…sion.object in selector

#2732
@typescript-eslint
Copy link

@typescript-eslint typescript-eslint bot commented Nov 4, 2020

Thanks for the PR, @ddubrava!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@bradzacher bradzacher added the bug label Nov 5, 2020
Copy link
Member

@bradzacher bradzacher left a comment

LGTM - nice and simple 😄 thanks a lot for the contribution!

@bradzacher bradzacher changed the title fix(eslint-plugin): [no-extra-non-null-assertion] add TSNonNullExpression.object in selector fix(eslint-plugin): [no-extra-non-null-assertion] false positive with non-nullable computed key Nov 5, 2020
@bradzacher bradzacher merged commit e82698c into typescript-eslint:master Nov 5, 2020
8 checks passed
8 checks passed
Typecheck
Details
Unit tests Unit tests
Details
Code style and lint
Details
Run integration tests on primary Node.js version
Details
Run unit tests on other Node.js versions (10.x)
Details
Run unit tests on other Node.js versions (14.x)
Details
Publish the latest code as a canary version
Details
Semantic Pull Request ready to be squashed
Details
@ddubrava ddubrava deleted the ddubrava:no-extra-non-null-assertion-optional-chaining#2732 branch Nov 15, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

2 participants