mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Check for type parameters on original type when getting type argument completions (#46614)
* Add failing test. * Check for type parameters on the original type when asking for the type argument constraint. * Update tests/cases/fourslash/stringLiteralTypeCompletionsInTypeArgForNonGeneric1.ts
This commit is contained in:
parent
bf6d164bd5
commit
6d33d8797b
@ -34729,7 +34729,8 @@ namespace ts {
|
||||
function getTypeArgumentConstraint(node: TypeNode): Type | undefined {
|
||||
const typeReferenceNode = tryCast(node.parent, isTypeReferenceType);
|
||||
if (!typeReferenceNode) return undefined;
|
||||
const typeParameters = getTypeParametersForTypeReference(typeReferenceNode)!; // TODO: GH#18217
|
||||
const typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
|
||||
if (!typeParameters) return undefined;
|
||||
const constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments!.indexOf(node)]);
|
||||
return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
|
||||
}
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
/// <reference path="./fourslash.ts" />
|
||||
|
||||
////interface Foo {}
|
||||
////type Bar = {};
|
||||
////
|
||||
////let x: Foo<"/*1*/">;
|
||||
////let y: Bar<"/*2*/">;
|
||||
|
||||
verify.completions({ marker: test.markers() });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user