mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-12 01:48:33 -05:00
Fix JSX completions after boolean property (#26943)
This commit is contained in:
@@ -986,7 +986,10 @@ namespace ts.Completions {
|
||||
break;
|
||||
case SyntaxKind.Identifier:
|
||||
// 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) {
|
||||
// Note for `<div someBool f>` we don't want to treat this as a jsx inializer, instead it's the attribute name.
|
||||
if (parent !== previousToken.parent &&
|
||||
!(parent as JsxAttribute).initializer &&
|
||||
findChildOfKind(parent, SyntaxKind.EqualsToken, sourceFile)) {
|
||||
isJsxInitializer = previousToken as Identifier;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,15 +8,22 @@
|
||||
//// interface IntrinsicElements {
|
||||
//// div: {
|
||||
//// /** Doc */
|
||||
//// foo: string
|
||||
//// foo: boolean;
|
||||
//// bar: string;
|
||||
//// }
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////<div /**/></div>;
|
||||
|
||||
goTo.marker();
|
||||
verify.completionEntryDetailIs("foo", "(JSX attribute) foo: string", "Doc", "JSX attribute", []);
|
||||
const exact: ReadonlyArray<FourSlashInterface.ExpectedCompletionEntry> = [
|
||||
{ name: "foo", kind: "JSX attribute", text: "(JSX attribute) foo: boolean", documentation: "Doc" },
|
||||
{ name: "bar", kind: "JSX attribute", text: "(JSX attribute) bar: string" },
|
||||
];
|
||||
verify.completions({ marker: "", exact });
|
||||
edit.insert("f");
|
||||
verify.completionEntryDetailIs("foo", "(JSX attribute) foo: string", "Doc", "JSX attribute", []);
|
||||
|
||||
verify.completions({ exact });
|
||||
edit.insert("oo ");
|
||||
verify.completions({ exact: exact[1] });
|
||||
edit.insert("b");
|
||||
verify.completions({ exact: exact[1] });
|
||||
|
||||
Reference in New Issue
Block a user