Skip to content

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

Closed
@RainingChain

Description

@RainingChain

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions