Skip to content

make the strict equality comparison operator a typeguard for string literal types #7447

Description

1.9.0-dev.20160217

Code

const hey: 'hey' = 'hey';
const value = Math.random() > 0.5 ? 'hey' : 'nay';
if (value === hey) {
   // here expected value to be of type 'hey' (we just asserted it), actual string
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Literal TypesUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedFixedA PR has been merged for this issueSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions