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

StrictNullCheck incorrectly prevents the use of the indexed access operator #20141

Closed
RainingChain opened this issue Nov 19, 2017 · 3 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@RainingChain
Copy link

TypeScript Version: 2.6.1

Code

class Klass {
  prop1:{innerNumber:number} | null;
  setInnerNumber(newInnerNumber:Klass['prop1']['innerNumber']){
    this.prop1 = {innerNumber:newInnerNumber}
  }
}
//Compile with --strictNullCheck

Expected behavior:
No error.

Actual behavior:
Property innerNumber does not exist on type '{ innerNumber:number;} | null'

Strict null check should not be checked for indexed access operator.

@ghost
Copy link

ghost commented Nov 19, 2017

Duplicate of #14366

@ghost ghost marked this as a duplicate of #14366 Nov 19, 2017
@ghost ghost added the Duplicate An existing issue was already created label Nov 19, 2017
@typescript-bot
Copy link
Collaborator

Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.

@mhegazy
Copy link
Contributor

mhegazy commented Mar 2, 2018

This should be doable today using NonNullable type

@microsoft microsoft locked and limited conversation to collaborators Jul 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

3 participants