Skip to content

Commit b0a985b

Browse files
a-tarasyukDanielRosenwasser
authored andcommitted
Add test for find-all-refs on string literal types in JsDoc for TypeScript files
1 parent dc8a10e commit b0a985b

File tree

5 files changed

+47
-2
lines changed

5 files changed

+47
-2
lines changed

src/services/utilities.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -790,8 +790,6 @@ namespace ts {
790790
}
791791

792792
export function getContextualTypeFromParentOrAncestorTypeNode(node: Expression, checker: TypeChecker): Type | undefined {
793-
if (node.flags & (NodeFlags.JSDoc & ~NodeFlags.JavaScriptFile)) return undefined;
794-
795793
const contextualType = getContextualTypeFromParent(node, checker);
796794
if (contextualType) return contextualType;
797795

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// === /a.ts ===
2+
// /**
3+
// * @type {"foo" | "bar"}
4+
// */
5+
// let x = "[|foo|]"/*FIND ALL REFS*/
6+
7+
[
8+
{
9+
"definition": {
10+
"containerKind": "",
11+
"containerName": "",
12+
"fileName": "/a.ts",
13+
"kind": "var",
14+
"name": "foo",
15+
"textSpan": {
16+
"start": 42,
17+
"length": 3
18+
},
19+
"displayParts": [
20+
{
21+
"text": "\"foo\"",
22+
"kind": "stringLiteral"
23+
}
24+
]
25+
},
26+
"references": [
27+
{
28+
"textSpan": {
29+
"start": 42,
30+
"length": 3
31+
},
32+
"fileName": "/a.ts",
33+
"isWriteAccess": false,
34+
"isInString": true
35+
}
36+
]
37+
}
38+
]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @filename: /a.ts
4+
/////**
5+
//// * @type {"foo" | "bar"}
6+
//// */
7+
////let x = "foo"/**/
8+
9+
verify.baselineFindAllReferences("");

0 commit comments

Comments
 (0)