Skip to content

Commit d99de73

Browse files
authored
Handle type argument lists as jsx completion starts (#28493)
* Handle type argument lists as jsx completion starts * preceeding -> preceding
1 parent 40bd7c8 commit d99de73

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/services/completions.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,6 +1532,7 @@ namespace ts.Completions {
15321532
if (contextToken) {
15331533
const parent = contextToken.parent;
15341534
switch (contextToken.kind) {
1535+
case SyntaxKind.GreaterThanToken: // End of a type argument list
15351536
case SyntaxKind.LessThanSlashToken:
15361537
case SyntaxKind.SlashToken:
15371538
case SyntaxKind.Identifier:
@@ -1540,6 +1541,10 @@ namespace ts.Completions {
15401541
case SyntaxKind.JsxAttribute:
15411542
case SyntaxKind.JsxSpreadAttribute:
15421543
if (parent && (parent.kind === SyntaxKind.JsxSelfClosingElement || parent.kind === SyntaxKind.JsxOpeningElement)) {
1544+
if (contextToken.kind === SyntaxKind.GreaterThanToken) {
1545+
const precedingToken = findPrecedingToken(contextToken.pos, sourceFile, /*startNode*/ undefined);
1546+
if (!(parent as JsxOpeningLikeElement).typeArguments || (precedingToken && precedingToken.kind === SyntaxKind.SlashToken)) break;
1547+
}
15431548
return <JsxOpeningLikeElement>parent;
15441549
}
15451550
else if (parent.kind === SyntaxKind.JsxAttribute) {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @jsx: preserve
4+
// @skipLibCheck: true
5+
// @Filename: file.tsx
6+
//// declare module JSX {
7+
//// interface Element { }
8+
//// interface IntrinsicElements {
9+
//// }
10+
//// interface ElementAttributesProperty { props; }
11+
//// }
12+
////
13+
////class Table<P> {
14+
//// constructor(public props: P) {}
15+
////}
16+
////
17+
////type Props = { widthInCol: number; text: string; };
18+
////
19+
/////**
20+
//// * @param width {number} Table width in px
21+
//// */
22+
////function createTable(width) {
23+
//// return <Table<Props> /*1*/ />
24+
////}
25+
////
26+
////createTable(800);
27+
28+
verify.completions({
29+
marker: "1",
30+
includes: ["widthInCol", "text"]
31+
});

0 commit comments

Comments
 (0)