Skip to content

Initializing let variables and exhaustiveness checking #22470

Description

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”.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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