-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
When calling a method declared as all<T1, T2>(values: [T1, T2]); I cannot use a union type array.
TypeScript Version:
1.8.10
Code
OK:
$q.all([a, b]).then(/*...*/);Error:
var promises = [a, b];
$q.all(promises).then(/*...*/);
> TS2329 Index signature is missing in type '(IPromise<A> | IPromise<B>)[]'Expected behavior:
It would be nice if both versions work, without explicitly reference types A and B. I think the problem is, that [a, b] infers to (A|B)[] instead of [A,B], which should prevent me from [a,b].push(new C()) (Is this the intension?). The problem is, that (A|B)[] looses the indexers [0]: A and [1]: B. I think that's what the error message wants to say?
Would it be possible to infer [a, b] to something like (A|B)[A, B] which is compatible to
interface IAB {
[i:number]: A|B;
[0]:A;
[1]:B;
}Btw. the error message is rather confusing, since (A|B)[] actually has an index signature.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed