@@ -17606,6 +17606,13 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
17606
17606
return getTypeOfSymbol(symbol); // intentionally doesn't use resolved symbol so type is cached as expected on the alias
17607
17607
}
17608
17608
else {
17609
+ const type = tryGetDeclaredTypeOfSymbol(resolvedSymbol); // call this first to ensure typeParameters is populated (if applicable)
17610
+ const typeParameters = type && getTypeParametersForTypeAndSymbol(type, resolvedSymbol);
17611
+ if (node.typeArguments && typeParameters) {
17612
+ addLazyDiagnostic(() => {
17613
+ checkTypeArgumentConstraints(node, typeParameters);
17614
+ });
17615
+ }
17609
17616
return getTypeReferenceType(node, resolvedSymbol); // getTypeReferenceType doesn't handle aliases - it must get the resolved symbol
17610
17617
}
17611
17618
}
@@ -37264,12 +37271,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
37264
37271
return getEffectiveTypeArguments(node, typeParameters)[index];
37265
37272
}
37266
37273
37267
- function getEffectiveTypeArguments(node: TypeReferenceNode | ExpressionWithTypeArguments, typeParameters: readonly TypeParameter[]): Type[] {
37274
+ function getEffectiveTypeArguments(node: TypeReferenceNode | ExpressionWithTypeArguments | NodeWithTypeArguments , typeParameters: readonly TypeParameter[]): Type[] {
37268
37275
return fillMissingTypeArguments(map(node.typeArguments!, getTypeFromTypeNode), typeParameters,
37269
37276
getMinTypeArgumentCount(typeParameters), isInJSFile(node));
37270
37277
}
37271
37278
37272
- function checkTypeArgumentConstraints(node: TypeReferenceNode | ExpressionWithTypeArguments, typeParameters: readonly TypeParameter[]): boolean {
37279
+ function checkTypeArgumentConstraints(node: TypeReferenceNode | ExpressionWithTypeArguments | NodeWithTypeArguments , typeParameters: readonly TypeParameter[]): boolean {
37273
37280
let typeArguments: Type[] | undefined;
37274
37281
let mapper: TypeMapper | undefined;
37275
37282
let result = true;
@@ -37290,13 +37297,20 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
37290
37297
return result;
37291
37298
}
37292
37299
37300
+ function getTypeParametersForTypeAndSymbol(type: Type, symbol: Symbol) {
37301
+ if (!isErrorType(type)) {
37302
+ return symbol.flags & SymbolFlags.TypeAlias && getSymbolLinks(symbol).typeParameters ||
37303
+ (getObjectFlags(type) & ObjectFlags.Reference ? (type as TypeReference).target.localTypeParameters : undefined);
37304
+ }
37305
+ return undefined;
37306
+ }
37307
+
37293
37308
function getTypeParametersForTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments) {
37294
37309
const type = getTypeFromTypeReference(node);
37295
37310
if (!isErrorType(type)) {
37296
37311
const symbol = getNodeLinks(node).resolvedSymbol;
37297
37312
if (symbol) {
37298
- return symbol.flags & SymbolFlags.TypeAlias && getSymbolLinks(symbol).typeParameters ||
37299
- (getObjectFlags(type) & ObjectFlags.Reference ? (type as TypeReference).target.localTypeParameters : undefined);
37313
+ return getTypeParametersForTypeAndSymbol(type, symbol);
37300
37314
}
37301
37315
}
37302
37316
return undefined;
0 commit comments