-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Incorrect inferring of return type #31254
Comments
Related: #30680 It is due to widening. |
effort level matching answer: don’t see a bug here, try SO |
I'd refer to #241 for explaining away a return type being wider than expected |
Something strange happens here declare function abc<T>(q: T | {id: 'Id'}[]): T
var u = abc([{id: 'Id'}]) // -> {id: 'Id'}[]
var k:{id: 'Id'}[] = u; // no problem
var l:typeof u = k; // no problem
var e:{id: 'Id'}[] = {} as {id: string}[]; // error (correct)
var p = k.map(v => v.id); // -> 'Id'[]
var t = l.map(v => v.id); // -> string[] (incorrect) |
|
This issue has been marked as a 'Duplicate' and has seen no recent activity. It has been automatically closed for house-keeping purposes. |
Version: 3.4.5
The text was updated successfully, but these errors were encountered: