mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Consistently use "JSX Attribute" completion kind (#19781)
* Consistently use "JSX Attribute" completion kind * Update tests and fix bug * Fix bug: In a JsxOpeningElement, if at an Identifier we are not at an attribute but at the tag itself. If at a GreaterThanToken, we are about to fill in an attribute.
This commit is contained in:
parent
3f248ecfe1
commit
6d273cfb33
@ -75,10 +75,16 @@ namespace ts.SymbolDisplay {
|
||||
}
|
||||
return unionPropertyKind;
|
||||
}
|
||||
if (location.parent && isJsxAttribute(location.parent)) {
|
||||
return ScriptElementKind.jsxAttribute;
|
||||
// If we requested completions after `x.` at the top-level, we may be at a source file location.
|
||||
switch (location.parent && location.parent.kind) {
|
||||
// If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'.
|
||||
case SyntaxKind.JsxOpeningElement:
|
||||
return location.kind === SyntaxKind.Identifier ? ScriptElementKind.memberVariableElement : ScriptElementKind.jsxAttribute;
|
||||
case SyntaxKind.JsxAttribute:
|
||||
return ScriptElementKind.jsxAttribute;
|
||||
default:
|
||||
return ScriptElementKind.memberVariableElement;
|
||||
}
|
||||
return ScriptElementKind.memberVariableElement;
|
||||
}
|
||||
|
||||
return ScriptElementKind.unknown;
|
||||
|
||||
22
tests/cases/fourslash/completionsJsxAttribute.ts
Normal file
22
tests/cases/fourslash/completionsJsxAttribute.ts
Normal file
@ -0,0 +1,22 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @jsx: preserve
|
||||
|
||||
// @Filename: /a.tsx
|
||||
////declare namespace JSX {
|
||||
//// interface Element {}
|
||||
//// interface IntrinsicElements {
|
||||
//// div: {
|
||||
//// /** Doc */
|
||||
//// foo: string
|
||||
//// }
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////<div /**/></div>;
|
||||
|
||||
goTo.marker();
|
||||
verify.completionEntryDetailIs("foo", "(JSX attribute) foo: string", "Doc ", "JSX attribute", []);
|
||||
edit.insert("f");
|
||||
verify.completionEntryDetailIs("foo", "(JSX attribute) foo: string", "Doc ", "JSX attribute", []);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user