mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
parent
edc88c51ca
commit
0ed523bb60
@ -1038,7 +1038,20 @@ namespace ts.Completions {
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.JsxExpression:
|
||||
// For `<div foo={true} [||] ></div>`, `parent` will be `{true}` and `previousToken` will be `}`
|
||||
if (previousToken.kind === SyntaxKind.CloseBraceToken && currentToken.kind === SyntaxKind.GreaterThanToken) {
|
||||
isJsxIdentifierExpected = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case SyntaxKind.JsxAttribute:
|
||||
// For `<div className="x" [||] ></div>`, `parent` will be JsxAttribute and `previousToken` will be its initializer
|
||||
if ((parent as JsxAttribute).initializer === previousToken &&
|
||||
previousToken.end < position) {
|
||||
isJsxIdentifierExpected = true;
|
||||
break;
|
||||
}
|
||||
switch (previousToken.kind) {
|
||||
case SyntaxKind.EqualsToken:
|
||||
isJsxInitializer = true;
|
||||
|
||||
27
tests/cases/fourslash/completionsJsxAttribute2.ts
Normal file
27
tests/cases/fourslash/completionsJsxAttribute2.ts
Normal file
@ -0,0 +1,27 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @jsx: preserve
|
||||
|
||||
// @Filename: /a.tsx
|
||||
////declare namespace JSX {
|
||||
//// interface Element {}
|
||||
//// interface IntrinsicElements {
|
||||
//// div: {
|
||||
//// /** Doc */
|
||||
//// foo: boolean;
|
||||
//// bar: string;
|
||||
//// "aria-foo": boolean;
|
||||
//// }
|
||||
//// }
|
||||
////}
|
||||
////
|
||||
////<div foo /*1*/></div>;
|
||||
////<div foo={true} /*2*/></div>;
|
||||
////<div bar="test" /*3*/></div>;
|
||||
////<div aria-foo /*4*/></div>;
|
||||
|
||||
|
||||
verify.completions({ marker: "1", exact: ["bar", "aria-foo"] });
|
||||
verify.completions({ marker: "2", exact: ["bar", "aria-foo"] });
|
||||
verify.completions({ marker: "3", exact: ["foo", "aria-foo"] });
|
||||
verify.completions({ marker: "4", exact: ["foo", "bar"] });
|
||||
Loading…
x
Reference in New Issue
Block a user