-
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
Unnecessary widening of function argument's type #19682
Comments
A smaller repro: type A = string & { n: number };
declare function from<T, U = T>(iterable: Iterable<T>, mapfn?: (v: T, k: number) => U): U[];
declare function concat<T>(a: ReadonlyArray<T>, b: ReadonlyArray<T>): T[];
declare const iterA: Iterable<A>;
const a: A[] = from(iterA); // OK
const cat: A[] = concat(a, from(iterA)); // Error It would work if you remove |
We need to split the |
@mhegazy Should that really be necessary? We usually recommend to unify signatures like that. |
The |
This one is actually caused by a subtle issue introduced by #18363. I have a fix that I will put up shortly. Meanwhile, the change to lib.d.ts is probably fine, but strictly speaking isn't needed. |
TypeScript Version: 2.6.1 (2.7.0-dev.20171102)
Code
Expected behavior:
No errors.
Actual behavior:
With
Array.from(a).concat(Array.from(b))
we have an errorArgument of type 'string[]' is not assignable to parameter of type 'Nominal<"A", string> | ReadonlyArray<Nominal<"A", string>>'.
In 2.5.3 it works fine.
The text was updated successfully, but these errors were encountered: