-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
infer extends number in conditional type handles '\n' incorrectly #50137
Comments
It doesn't make sense... |
Same feeling. It's a valid JS |
IIRC you can pass anything that is compatible with |
Not just |
@ahejlsberg this seems like wrong behavior - can you confirm? |
I would like to point out that due to the consecutive placeholders... type Foo = '812' extends `${infer T extends number}${infer R}` ? T : never;
// ^? type Foo = 8 ... |
@fatcerberus You are looking for #46124 (comment) ? |
@RyanCavanaugh It does seem like odd behavior, but the expression |
by the way, for whoever does this (can I do it? seems really small?) I happened to notice that it's not just empty whitespace you gotta check for, but also whitespace that surrounds (otherwise valid) numbers. So type Foo = ' \t\n001234e1\r\u0020\u2029 ' extends `${infer T extends number}` ? T : never;
// ^? number |
Bug Report
π Search Terms
π 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
π Actual behavior
Foo
isnumber
π Expected behavior
Foo
should benever
The text was updated successfully, but these errors were encountered: