mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-20 10:29:36 -06:00
fixStrictClassInitialization: Support array initializer (#24810)
This commit is contained in:
parent
8c7a9ccc27
commit
04187bde8d
@ -3056,12 +3056,12 @@ namespace ts {
|
||||
/* @internal */ getSymbolCount(): number;
|
||||
/* @internal */ getTypeCount(): number;
|
||||
|
||||
/* @internal */ isArrayLikeType(type: Type): boolean;
|
||||
/**
|
||||
* For a union, will include a property if it's defined in *any* of the member types.
|
||||
* So for `{ a } | { b }`, this will include both `a` and `b`.
|
||||
* Does not include properties of primitive types.
|
||||
*/
|
||||
/* @internal */ isArrayLikeType(type: Type): boolean;
|
||||
/* @internal */ getAllPossiblePropertiesOfTypes(type: ReadonlyArray<Type>): Symbol[];
|
||||
/* @internal */ resolveName(name: string, location: Node, meaning: SymbolFlags, excludeGlobals: boolean): Symbol | undefined;
|
||||
/* @internal */ getJsxNamespace(location?: Node): string;
|
||||
|
||||
@ -127,6 +127,9 @@ namespace ts.codefix {
|
||||
|
||||
return createNew(createIdentifier(type.symbol.name), /*typeArguments*/ undefined, /*argumentsArray*/ undefined);
|
||||
}
|
||||
else if (checker.isArrayLikeType(type)) {
|
||||
return createArrayLiteral();
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
@ -35,6 +35,8 @@
|
||||
//// k: AT;
|
||||
////
|
||||
//// l: Foo;
|
||||
////
|
||||
//// m: number[];
|
||||
//// }
|
||||
|
||||
verify.codeFixAll({
|
||||
@ -73,5 +75,7 @@ class T {
|
||||
k: AT = new AT;
|
||||
|
||||
l: Foo = new Foo;
|
||||
|
||||
m: number[] = [];
|
||||
}`
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user