Skip to content

Commit

Permalink
Cherry-pick PR #46614 into release-4.5 (#46675)
Browse files Browse the repository at this point in the history
Component commits:
e77514a Add failing test.

3c0d51b Check for type parameters on the original type when asking for the type argument constraint.

e7c8095 Update tests/cases/fourslash/stringLiteralTypeCompletionsInTypeArgForNonGeneric1.ts

Co-authored-by: Daniel Rosenwasser <drosen@microsoft.com>
  • Loading branch information
typescript-bot and DanielRosenwasser committed Nov 3, 2021
1 parent e4a2494 commit 0651bd3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/compiler/checker.ts
Expand Up @@ -34730,7 +34730,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)));
}
Expand Down
@@ -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() });

0 comments on commit 0651bd3

Please sign in to comment.