mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-15 12:51:30 -05:00
Handle type argument lists as jsx completion starts (#28493)
* Handle type argument lists as jsx completion starts * preceeding -> preceding
This commit is contained in:
@@ -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 <JsxOpeningLikeElement>parent;
|
||||
}
|
||||
else if (parent.kind === SyntaxKind.JsxAttribute) {
|
||||
|
||||
31
tests/cases/fourslash/tsxCompletionsGenericComponent.ts
Normal file
31
tests/cases/fourslash/tsxCompletionsGenericComponent.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @jsx: preserve
|
||||
// @skipLibCheck: true
|
||||
// @Filename: file.tsx
|
||||
//// declare module JSX {
|
||||
//// interface Element { }
|
||||
//// interface IntrinsicElements {
|
||||
//// }
|
||||
//// interface ElementAttributesProperty { props; }
|
||||
//// }
|
||||
////
|
||||
////class Table<P> {
|
||||
//// constructor(public props: P) {}
|
||||
////}
|
||||
////
|
||||
////type Props = { widthInCol: number; text: string; };
|
||||
////
|
||||
/////**
|
||||
//// * @param width {number} Table width in px
|
||||
//// */
|
||||
////function createTable(width) {
|
||||
//// return <Table<Props> /*1*/ />
|
||||
////}
|
||||
////
|
||||
////createTable(800);
|
||||
|
||||
verify.completions({
|
||||
marker: "1",
|
||||
includes: ["widthInCol", "text"]
|
||||
});
|
||||
Reference in New Issue
Block a user