mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
Fix inference for generic-typed constructor parameter when no explicit constructor is present (#47750)
* assume signature is from constructor if declaration is undefined * add tests and baselines
This commit is contained in:
@@ -13077,8 +13077,11 @@ namespace ts {
|
||||
// object type literal or interface (using the new keyword). Each way of declaring a constructor
|
||||
// will result in a different declaration kind.
|
||||
if (!signature.isolatedSignatureType) {
|
||||
const kind = signature.declaration ? signature.declaration.kind : SyntaxKind.Unknown;
|
||||
const isConstructor = kind === SyntaxKind.Constructor || kind === SyntaxKind.ConstructSignature || kind === SyntaxKind.ConstructorType;
|
||||
const kind = signature.declaration?.kind;
|
||||
|
||||
// If declaration is undefined, it is likely to be the signature of the default constructor.
|
||||
const isConstructor = kind === undefined || kind === SyntaxKind.Constructor || kind === SyntaxKind.ConstructSignature || kind === SyntaxKind.ConstructorType;
|
||||
|
||||
const type = createObjectType(ObjectFlags.Anonymous);
|
||||
type.members = emptySymbols;
|
||||
type.properties = emptyArray;
|
||||
|
||||
Reference in New Issue
Block a user