fix(46998): Hover on as const shows type const = /*unresolved*/ any (#47000)

This commit is contained in:
Oleksandr T 2021-12-07 00:41:46 +02:00 committed by GitHub
parent 1fe9bfdd0e
commit 4761ba6285
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 267 additions and 1 deletions

View File

@ -330,7 +330,7 @@ namespace ts.SymbolDisplay {
displayParts.push(spacePart());
displayParts.push(operatorPart(SyntaxKind.EqualsToken));
displayParts.push(spacePart());
addRange(displayParts, typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, TypeFormatFlags.InTypeAlias));
addRange(displayParts, typeToDisplayParts(typeChecker, isConstTypeReference(location.parent) ? typeChecker.getTypeAtLocation(location.parent) : typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, TypeFormatFlags.InTypeAlias));
}
if (symbolFlags & SymbolFlags.Enum) {
prefixNextMeaning();

View File

@ -0,0 +1,258 @@
[
{
"marker": {
"fileName": "/tests/cases/fourslash/quickInfoForConstAssertions.ts",
"position": 22,
"name": "1"
},
"quickInfo": {
"kind": "type",
"kindModifiers": "",
"textSpan": {
"start": 22,
"length": 5
},
"displayParts": [
{
"text": "type",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "const",
"kind": "aliasName"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=",
"kind": "operator"
},
{
"text": " ",
"kind": "space"
},
{
"text": "{",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": " ",
"kind": "space"
},
{
"text": "readonly",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "a",
"kind": "propertyName"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "1",
"kind": "stringLiteral"
},
{
"text": ";",
"kind": "punctuation"
},
{
"text": "\n",
"kind": "lineBreak"
},
{
"text": "}",
"kind": "punctuation"
}
],
"documentation": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/quickInfoForConstAssertions.ts",
"position": 44,
"name": "2"
},
"quickInfo": {
"kind": "type",
"kindModifiers": "",
"textSpan": {
"start": 44,
"length": 5
},
"displayParts": [
{
"text": "type",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "const",
"kind": "aliasName"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=",
"kind": "operator"
},
{
"text": " ",
"kind": "space"
},
{
"text": "1",
"kind": "stringLiteral"
}
],
"documentation": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/quickInfoForConstAssertions.ts",
"position": 68,
"name": "3"
},
"quickInfo": {
"kind": "type",
"kindModifiers": "",
"textSpan": {
"start": 68,
"length": 5
},
"displayParts": [
{
"text": "type",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "const",
"kind": "aliasName"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=",
"kind": "operator"
},
{
"text": " ",
"kind": "space"
},
{
"text": "\"c\"",
"kind": "stringLiteral"
}
],
"documentation": []
}
},
{
"marker": {
"fileName": "/tests/cases/fourslash/quickInfoForConstAssertions.ts",
"position": 95,
"name": "4"
},
"quickInfo": {
"kind": "type",
"kindModifiers": "",
"textSpan": {
"start": 95,
"length": 5
},
"displayParts": [
{
"text": "type",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "const",
"kind": "aliasName"
},
{
"text": " ",
"kind": "space"
},
{
"text": "=",
"kind": "operator"
},
{
"text": " ",
"kind": "space"
},
{
"text": "readonly",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "[",
"kind": "punctuation"
},
{
"text": "1",
"kind": "stringLiteral"
},
{
"text": ",",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "2",
"kind": "stringLiteral"
},
{
"text": "]",
"kind": "punctuation"
}
],
"documentation": []
}
}
]

View File

@ -0,0 +1,8 @@
/// <reference path="fourslash.ts" />
////const a = { a: 1 } as /*1*/const;
////const b = 1 as /*2*/const;
////const c = "c" as /*3*/const;
////const d = [1, 2] as /*4*/const;
verify.baselineQuickInfo();