microsoft / microsoft/TypeScript
Compiler Errors TS1110 and TS2345 with integer type pattern
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
TypeScript Version: 3.0.3
Explicitly marked positive integers are not recognized in a type pattern:
foo(direction: -1 | 1 | -2 | +2) { }

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

Expected behavior:
As everywhere else, the unary operator + should be allowed in a type pattern.
This is not urgent, just for completeness.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Reproduce the example with TypeScript 3.0.3, checking both the type pattern -1 | 1 | -2 | +2 and calls using integer values; done means unary + is accepted in the type pattern and the corresponding TS1110 and TS2345 errors no longer occur.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100