Skip to content

Compiler Errors TS1110 and TS2345 with integer type pattern #27178

Open
@frevds

Description

TypeScript Version: 3.0.3

Explicitly marked positive integers are not recognized in a type pattern:

    foo(direction: -1 | 1 | -2 | +2) { }

image

Likewise, calling it using a perfectly legit integer fails with TS2345:

image

Expected behavior:

As everywhere else, the unary operator + should be allowed in a type pattern.
This is not urgent, just for completeness.

Activity

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

Metadata

Assignees

No one assigned

    Labels

    Domain: Literal TypesUnit types including string literal types, numeric literal types, Boolean literals, null, undefinedIn DiscussionNot yet reached consensusSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions