diff --git a/src/services/completions.ts b/src/services/completions.ts index 90c005d2131a4..488af58a2f069 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1532,6 +1532,7 @@ namespace ts.Completions { if (contextToken) { const parent = contextToken.parent; switch (contextToken.kind) { + case SyntaxKind.GreaterThanToken: // End of a type argument list case SyntaxKind.LessThanSlashToken: case SyntaxKind.SlashToken: case SyntaxKind.Identifier: @@ -1540,6 +1541,10 @@ namespace ts.Completions { case SyntaxKind.JsxAttribute: case SyntaxKind.JsxSpreadAttribute: if (parent && (parent.kind === SyntaxKind.JsxSelfClosingElement || parent.kind === SyntaxKind.JsxOpeningElement)) { + if (contextToken.kind === SyntaxKind.GreaterThanToken) { + const precedingToken = findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined); + if (!(parent as JsxOpeningLikeElement).typeArguments || (precedingToken && precedingToken.kind === SyntaxKind.SlashToken)) break; + } return parent; } else if (parent.kind === SyntaxKind.JsxAttribute) { diff --git a/tests/cases/fourslash/tsxCompletionsGenericComponent.ts b/tests/cases/fourslash/tsxCompletionsGenericComponent.ts new file mode 100644 index 0000000000000..0414599d6e5a6 --- /dev/null +++ b/tests/cases/fourslash/tsxCompletionsGenericComponent.ts @@ -0,0 +1,31 @@ +/// + +// @jsx: preserve +// @skipLibCheck: true +// @Filename: file.tsx +//// declare module JSX { +//// interface Element { } +//// interface IntrinsicElements { +//// } +//// interface ElementAttributesProperty { props; } +//// } +//// +////class Table

{ +//// constructor(public props: P) {} +////} +//// +////type Props = { widthInCol: number; text: string; }; +//// +/////** +//// * @param width {number} Table width in px +//// */ +////function createTable(width) { +//// return /*1*/ /> +////} +//// +////createTable(800); + +verify.completions({ + marker: "1", + includes: ["widthInCol", "text"] +});