-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Wrong unknown
inference after String()
in 4.1.0-dev.20200819
#40132
Comments
Press run, and see:
|
This is a known break coming up in 4.1, but pinging @andrewbranch just because we want to watch the issue tracker to gauge impact here. |
@AlCalzone and @DanielRosenwasser: Okay forgot the |
@RyanCavanaugh duplicate of what? #39113 is the causing issue, not a duplicate ... |
But change type ThrownError = { code: unknown; }
const thrownError: ThrownError = {code: 0};
const thrownErrorCode = thrownError?.code && String(thrownError.code);
const str: string = thrownErrorCode;
str.toLocaleLowerCase(); |
Yep, the actual domain of of |
TypeScript Version: 4.1.0-dev.20200819
Search Terms: unknown inference string
Code
Expected behavior: No Error
Actual behavior:
Error: Type 'unknown' is not assignable to type 'string'.(2322) in the last line.
Playground Link:
https://www.typescriptlang.org/play?ts=4.1.0-dev.20200819#code/CYUwxgNghgTiAEYD2A7AzgF3hgFjJA7igKIz4wBc8A3okqAPxUCuKA1ioSgNzwC+AWABQw5Oiy58RUuQDC9BAF5seLjKQwGAOmSh4AMn3wAyhhgBLFAHMAFJLVkNOhQEpuw0akzxMlH2csreAAfeFZQADNLEGB4ZXtpRxh5UHchIA
Working version with 4.1.0-dev.20200818:
https://www.typescriptlang.org/play?ts=4.1.0-dev.20200818#code/CYUwxgNghgTiAEYD2A7AzgF3hgFjJA7igKIz4wBc8A3okqAPxUCuKA1ioSgNzwC+AWABQw5Oiy58RUuQDC9BAF5seLjKQwGAOmSh4AMn3wAyhhgBLFAHMAFJLVkNOhQEpuw0akzxMlH2csreAAfeFZQADNLEGB4ZXtpRxh5UHchIA
EDIT: Added missing
| undefined
The text was updated successfully, but these errors were encountered: