mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-17 21:06:50 -05:00
Add related span for mixin constructor error (#28319)
* Add related span for mixin constructor error * Remove unneeded casts * Nicer style
This commit is contained in:
@@ -5674,7 +5674,18 @@ namespace ts {
|
||||
return type.resolvedBaseConstructorType = errorType;
|
||||
}
|
||||
if (!(baseConstructorType.flags & TypeFlags.Any) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) {
|
||||
error(baseTypeNode.expression, Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
|
||||
const err = error(baseTypeNode.expression, Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
|
||||
if (baseConstructorType.flags & TypeFlags.TypeParameter) {
|
||||
const constraint = getConstraintFromTypeParameter(baseConstructorType);
|
||||
let ctorReturn: Type = unknownType;
|
||||
if (constraint) {
|
||||
const ctorSig = getSignaturesOfType(constraint, SignatureKind.Construct);
|
||||
if (ctorSig[0]) {
|
||||
ctorReturn = getReturnTypeOfSignature(ctorSig[0]);
|
||||
}
|
||||
}
|
||||
addRelatedInfo(err, createDiagnosticForNode(baseConstructorType.symbol.declarations[0], Diagnostics.Did_you_mean_for_0_to_be_constrained_to_type_new_args_Colon_any_1, symbolToString(baseConstructorType.symbol), typeToString(ctorReturn)));
|
||||
}
|
||||
return type.resolvedBaseConstructorType = errorType;
|
||||
}
|
||||
type.resolvedBaseConstructorType = baseConstructorType;
|
||||
|
||||
@@ -2493,6 +2493,10 @@
|
||||
"category": "Error",
|
||||
"code": 2734
|
||||
},
|
||||
"Did you mean for '{0}' to be constrained to type 'new (...args: any[]) => {1}'?": {
|
||||
"category": "Error",
|
||||
"code": 2735
|
||||
},
|
||||
|
||||
"Import declaration '{0}' is using private name '{1}'.": {
|
||||
"category": "Error",
|
||||
|
||||
Reference in New Issue
Block a user