Skip to content

Commit 8717a7b

Browse files
author
Andy
authored
Fix bug: <div a="1" b/**/ > is not a jsx initializer (#23138) (#23167)
* Fix bug: `<div a="1" b/**/ >` is not a jsx initializer (#23138) * Don't use test feature only available in master branch
1 parent 4d783d0 commit 8717a7b

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/services/completions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,8 @@ namespace ts.Completions {
925925
isJsxInitializer = true;
926926
break;
927927
case SyntaxKind.Identifier:
928-
if (previousToken !== (parent as JsxAttribute).name) {
928+
// For `<div x=[|f/**/|]`, `parent` will be `x` and `previousToken.parent` will be `f` (which is its own JsxAttribute)
929+
if (parent !== previousToken.parent && !(parent as JsxAttribute).initializer) {
929930
isJsxInitializer = previousToken as Identifier;
930931
}
931932
}
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
/// <reference path="fourslash.ts" />
22

33
// @Filename: /a.tsx
4+
////declare namespace JSX {
5+
//// interface IntrinsicElements {
6+
//// div: { a: string, b: string }
7+
//// }
8+
////}
49
////const foo = 0;
5-
////<div x=[|f/**/|] />;
10+
////<div x=[|f/*0*/|] />;
11+
////
12+
////<div a="1" b/*1*/ />
13+
////<div a /*2*/ />
614

715
const [replacementSpan] = test.ranges();
8-
goTo.marker();
16+
goTo.marker("0");
917
verify.completionListContains("foo", "const foo: 0", undefined, "const", undefined, undefined, {
1018
includeInsertTextCompletions: true,
1119
insertText: "{foo}",
1220
replacementSpan,
1321
});
22+
23+
verify.completionsAt("1", ["b"]);
24+
verify.completionsAt("2", ["b"]);

0 commit comments

Comments
 (0)