infer extends number in conditional type handles '\n' incorrectly
See original GitHub issueBug Report
🔎 Search Terms
- infer extends number
🕗 Version & Regression Information
4.8.0-beta (in playground)
⏯ Playground Link
Playground link with relevant code
A simple type-level JSON parser encounters this issue
💻 Code
// number
type Foo = '\n' extends `${infer T extends number}${infer R}` ? T : never;
🙁 Actual behavior
Foo
is number
🙂 Expected behavior
Foo
should be never
Issue Analytics
- State:
- Created a year ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Conditional type is inferred differently with generic type
The issue is that the compiler does not consult generic constraints when evaluating conditional types that depend upon as-yet-unspecified ...
Read more >Common issues and solutions - mypy 0.991 documentation
The reason is that if the type of a is unknown, the type of a.split() is also unknown, so it is inferred as...
Read more >Chapter 18. Type Inference
Describing how inference is used to handle wildcard-parameterized functional interface target types and most specific method analysis.
Read more >Semantics
So in type checked Groovy, flow typing is a very important concept, which also implies that if @TypeChecked is applied, methods are selected ......
Read more >Useful Patterns by Use Case - React TypeScript Cheatsheets
Strategy: extend React. ... no error return <Button type="button"> text </Button>; ... Strategy: extract a component's props by inferring them. Example:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@fatcerberus You are looking for https://github.com/microsoft/TypeScript/issues/46124#issuecomment-930388594 ?
Not just
parseInt()
—butNumber()
. It uses theStringNumericLiteral
production, which means0b111
is a`${number}`
as well. (Disclaimer: didn’t read that source code; this is based on experiment).