fix(54902): Incorrect quick info on using declarations (#54912)
This commit is contained in:
Родитель
b1da6eead3
Коммит
f38e0fe6f0
|
@ -60,7 +60,9 @@ import {
|
|||
isThisInTypeQuery,
|
||||
isTransientSymbol,
|
||||
isTypeAliasDeclaration,
|
||||
isVarAwaitUsing,
|
||||
isVarConst,
|
||||
isVarUsing,
|
||||
JSDocTagInfo,
|
||||
JsxOpeningLikeElement,
|
||||
keywordPart,
|
||||
|
@ -161,6 +163,12 @@ function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeCheck
|
|||
else if (symbol.valueDeclaration && isVarConst(symbol.valueDeclaration as VariableDeclaration)) {
|
||||
return ScriptElementKind.constElement;
|
||||
}
|
||||
else if (symbol.valueDeclaration && isVarUsing(symbol.valueDeclaration as VariableDeclaration)) {
|
||||
return ScriptElementKind.variableUsingElement;
|
||||
}
|
||||
else if (symbol.valueDeclaration && isVarAwaitUsing(symbol.valueDeclaration as VariableDeclaration)) {
|
||||
return ScriptElementKind.variableAwaitUsingElement;
|
||||
}
|
||||
else if (forEach(symbol.declarations, isLet)) {
|
||||
return ScriptElementKind.letElement;
|
||||
}
|
||||
|
@ -630,6 +638,8 @@ export function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: Typ
|
|||
symbolFlags & SymbolFlags.Variable ||
|
||||
symbolKind === ScriptElementKind.localVariableElement ||
|
||||
symbolKind === ScriptElementKind.indexSignatureElement ||
|
||||
symbolKind === ScriptElementKind.variableUsingElement ||
|
||||
symbolKind === ScriptElementKind.variableAwaitUsingElement ||
|
||||
isThisExpression) {
|
||||
displayParts.push(punctuationPart(SyntaxKind.ColonToken));
|
||||
displayParts.push(spacePart());
|
||||
|
@ -807,6 +817,8 @@ export function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker: Typ
|
|||
case ScriptElementKind.letElement:
|
||||
case ScriptElementKind.constElement:
|
||||
case ScriptElementKind.constructorImplementationElement:
|
||||
case ScriptElementKind.variableUsingElement:
|
||||
case ScriptElementKind.variableAwaitUsingElement:
|
||||
displayParts.push(textOrKeywordPart(symbolKind));
|
||||
return;
|
||||
default:
|
||||
|
|
|
@ -1596,6 +1596,12 @@ export const enum ScriptElementKind {
|
|||
/** Inside function */
|
||||
localVariableElement = "local var",
|
||||
|
||||
/** using foo = ... */
|
||||
variableUsingElement = "using",
|
||||
|
||||
/** await using foo = ... */
|
||||
variableAwaitUsingElement = "await using",
|
||||
|
||||
/**
|
||||
* Inside module and script only
|
||||
* function f() { }
|
||||
|
|
|
@ -10978,6 +10978,10 @@ declare namespace ts {
|
|||
variableElement = "var",
|
||||
/** Inside function */
|
||||
localVariableElement = "local var",
|
||||
/** using foo = ... */
|
||||
variableUsingElement = "using",
|
||||
/** await using foo = ... */
|
||||
variableAwaitUsingElement = "await using",
|
||||
/**
|
||||
* Inside module and script only
|
||||
* function f() { }
|
||||
|
|
|
@ -7009,6 +7009,10 @@ declare namespace ts {
|
|||
variableElement = "var",
|
||||
/** Inside function */
|
||||
localVariableElement = "local var",
|
||||
/** using foo = ... */
|
||||
variableUsingElement = "using",
|
||||
/** await using foo = ... */
|
||||
variableAwaitUsingElement = "await using",
|
||||
/**
|
||||
* Inside module and script only
|
||||
* function f() { }
|
||||
|
|
|
@ -0,0 +1,174 @@
|
|||
=== /tests/cases/fourslash/quickInfoDisplayPartsUsing.ts ===
|
||||
// using a = "a";
|
||||
// ^
|
||||
// | ----------------------------------------------------------------------
|
||||
// | using a: "a"
|
||||
// | ----------------------------------------------------------------------
|
||||
// const f = async () => {
|
||||
// await using b = { async [Symbol.asyncDispose]() {} };
|
||||
// ^
|
||||
// | ----------------------------------------------------------------------
|
||||
// | await using b: {
|
||||
// | [Symbol.asyncDispose](): Promise<void>;
|
||||
// | }
|
||||
// | ----------------------------------------------------------------------
|
||||
// };
|
||||
|
||||
[
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/quickInfoDisplayPartsUsing.ts",
|
||||
"position": 7,
|
||||
"name": "a"
|
||||
},
|
||||
"item": {
|
||||
"kind": "using",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 6,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "using",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "a",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "\"a\"",
|
||||
"kind": "stringLiteral"
|
||||
}
|
||||
],
|
||||
"documentation": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"marker": {
|
||||
"fileName": "/tests/cases/fourslash/quickInfoDisplayPartsUsing.ts",
|
||||
"position": 55,
|
||||
"name": "b"
|
||||
},
|
||||
"item": {
|
||||
"kind": "await using",
|
||||
"kindModifiers": "",
|
||||
"textSpan": {
|
||||
"start": 55,
|
||||
"length": 1
|
||||
},
|
||||
"displayParts": [
|
||||
{
|
||||
"text": "await using",
|
||||
"kind": "text"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "b",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "{",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "[",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "Symbol",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": ".",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "asyncDispose",
|
||||
"kind": "propertyName"
|
||||
},
|
||||
{
|
||||
"text": "]",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "(",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ")",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ":",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": " ",
|
||||
"kind": "space"
|
||||
},
|
||||
{
|
||||
"text": "Promise",
|
||||
"kind": "localName"
|
||||
},
|
||||
{
|
||||
"text": "<",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "void",
|
||||
"kind": "keyword"
|
||||
},
|
||||
{
|
||||
"text": ">",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": ";",
|
||||
"kind": "punctuation"
|
||||
},
|
||||
{
|
||||
"text": "\n",
|
||||
"kind": "lineBreak"
|
||||
},
|
||||
{
|
||||
"text": "}",
|
||||
"kind": "punctuation"
|
||||
}
|
||||
],
|
||||
"documentation": []
|
||||
}
|
||||
}
|
||||
]
|
|
@ -0,0 +1,9 @@
|
|||
/// <reference path="fourslash.ts" />
|
||||
// @lib: esnext
|
||||
|
||||
////using a/*a*/ = "a";
|
||||
////const f = async () => {
|
||||
//// await using /*b*/b = { async [Symbol.asyncDispose]() {} };
|
||||
////};
|
||||
|
||||
verify.baselineQuickInfo();
|
Загрузка…
Ссылка в новой задаче