mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Fix isInJsxText after JSXOpeningElement with type arguments (#34958)
* Fix `isInJsxText` after JSXOpeningElement with type arguments * Do the same thing a different way
This commit is contained in:
@@ -1688,7 +1688,16 @@ namespace ts.Completions {
|
||||
|
||||
if (contextToken.kind === SyntaxKind.GreaterThanToken && contextToken.parent) {
|
||||
if (contextToken.parent.kind === SyntaxKind.JsxOpeningElement) {
|
||||
return true;
|
||||
// Two possibilities:
|
||||
// 1. <div>/**/
|
||||
// - contextToken: GreaterThanToken (before cursor)
|
||||
// - location: JSXElement
|
||||
// - different parents (JSXOpeningElement, JSXElement)
|
||||
// 2. <Component<string> /**/>
|
||||
// - contextToken: GreaterThanToken (before cursor)
|
||||
// - location: GreaterThanToken (after cursor)
|
||||
// - same parent (JSXOpeningElement)
|
||||
return location.parent.kind !== SyntaxKind.JsxOpeningElement;
|
||||
}
|
||||
|
||||
if (contextToken.parent.kind === SyntaxKind.JsxClosingElement || contextToken.parent.kind === SyntaxKind.JsxSelfClosingElement) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @Filename: /a.tsx
|
||||
////declare const React: any;
|
||||
////declare function CustomComponent<T>(props: { name: string }): JSX.Element;
|
||||
////const element1 = <CustomComponent<string> /*1*/></CustomComponent>;
|
||||
////const element2 = <CustomComponent<string> /*2*/ />;
|
||||
|
||||
['1', '2'].forEach(marker =>
|
||||
verify.completions({
|
||||
marker,
|
||||
exact: [{
|
||||
name: 'name',
|
||||
kind: 'JSX attribute',
|
||||
kindModifiers: 'declare'
|
||||
}]
|
||||
})
|
||||
);
|
||||
Reference in New Issue
Block a user