Add test for find-all-refs on string literal types in JsDoc for TypeScript files

This commit is contained in:
Oleksandr T
2022-10-04 11:40:38 +03:00
committed by Daniel Rosenwasser
parent dc8a10ee99
commit b0a985bf0b
5 changed files with 47 additions and 2 deletions

View File

@@ -790,8 +790,6 @@ namespace ts {
}
export function getContextualTypeFromParentOrAncestorTypeNode(node: Expression, checker: TypeChecker): Type | undefined {
if (node.flags & (NodeFlags.JSDoc & ~NodeFlags.JavaScriptFile)) return undefined;
const contextualType = getContextualTypeFromParent(node, checker);
if (contextualType) return contextualType;

View File

@@ -0,0 +1,38 @@
// === /a.ts ===
// /**
// * @type {"foo" | "bar"}
// */
// let x = "[|foo|]"/*FIND ALL REFS*/
[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/a.ts",
"kind": "var",
"name": "foo",
"textSpan": {
"start": 42,
"length": 3
},
"displayParts": [
{
"text": "\"foo\"",
"kind": "stringLiteral"
}
]
},
"references": [
{
"textSpan": {
"start": 42,
"length": 3
},
"fileName": "/a.ts",
"isWriteAccess": false,
"isInString": true
}
]
}
]

View File

@@ -0,0 +1,9 @@
/// <reference path="fourslash.ts" />
// @filename: /a.ts
/////**
//// * @type {"foo" | "bar"}
//// */
////let x = "foo"/**/
verify.baselineFindAllReferences("");