Skip to content

Initializing let variables and exhaustiveness checking #22470

@rauschma

Description

@rauschma
let tagName;
switch (kind) {
  case ListKind.Ordered:
    tagName = 'ol';
    break;
  case ListKind.Unordered:
    tagName = 'ul';
    break;
  default:
    assertNever(kind);
}
  • The inferred type of tagName is string|undefined, but should be string, AFAICT.
  • Similarly: If I give tagName the type string, I get the error: “Variable 'tagName' is used before being assigned”.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions