Skip to content

False positive "Object is possibly 'null'" error #1056

Open
@vladimir-tikhonov

Description

@vladimir-tikhonov

Note: it appears only in the last nightly version, so it's probably caused by one of the pull requests merged yesterday.

webassembly studio: https://webassembly.studio/?f=ih6p4z4fub

The following code is now producing an invalid error during compilation:

class Container {
  public another: Another|null = null;
}

class Another {
  public prop: i32 = 0;
}

export function doStuff( container: Container ): void {
  if ( container.another !== null && container.another.prop > 1 ) { // TS2531: Object is possibly 'null'
    container.another.prop = 2;
  }
}

This was not a case previously and not a case in the current version of typescript.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions