Skip to content

language service: Null is not removed from type using ?. operator #15885

@chuckjaz

Description

@chuckjaz

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting

Current behavior

Language service does not correctly remove null from types when using the ?. operator.

Minimal reproduction of the problem with instructions

  1. Start with the quickstart example.

  2. Add "strictNullChecks": true to the tsconfig.json file.

  3. To AppComponent in app.component.ts add:

test: {a: number, b: number} | null = {
    a: 1,
    b: 2
  }
  1. To the template in app.component.ts add:
  {{test?.a}}

EXPECTED: No errors and the hover over a to show a member of the anonymous type defined in AppComponent
RECEIVED: A diagnostic Identifier 'a' is not defined.

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