Answer the question
In order to leave comments, you need to log in
Why can't create type Object[] in typescript?
I have a simple code
class A<T extends Object[]> {
public B: T = [{ a: 1 }, { b: 2 }];
}
Type "({ a: number; } | { b: number; })[]" cannot be assigned to type "T".
"({ a: number; } | { b: number; })[]" can be assigned to a constraint of type "T", but it is possible to instantiate "T" with a different constraint subtype "Object".ts(2322)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question