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
This commit is contained in:
Andy 2018-04-05 09:17:34 -07:00 committed by GitHub
parent 4d783d0bff
commit 8717a7bcf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -925,7 +925,8 @@ namespace ts.Completions {
isJsxInitializer = true;
break;
case SyntaxKind.Identifier:
if (previousToken !== (parent as JsxAttribute).name) {
// For `<div x=[|f/**/|]`, `parent` will be `x` and `previousToken.parent` will be `f` (which is its own JsxAttribute)
if (parent !== previousToken.parent && !(parent as JsxAttribute).initializer) {
isJsxInitializer = previousToken as Identifier;
}
}

View File

@ -1,13 +1,24 @@
/// <reference path="fourslash.ts" />
// @Filename: /a.tsx
////declare namespace JSX {
//// interface IntrinsicElements {
//// div: { a: string, b: string }
//// }
////}
////const foo = 0;
////<div x=[|f/**/|] />;
////<div x=[|f/*0*/|] />;
////
////<div a="1" b/*1*/ />
////<div a /*2*/ />
const [replacementSpan] = test.ranges();
goTo.marker();
goTo.marker("0");
verify.completionListContains("foo", "const foo: 0", undefined, "const", undefined, undefined, {
includeInsertTextCompletions: true,
insertText: "{foo}",
replacementSpan,
});
verify.completionsAt("1", ["b"]);
verify.completionsAt("2", ["b"]);