mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-14 07:02:44 -05:00
Add test for find-all-refs on string literal types in JsDoc for TypeScript files
This commit is contained in:
committed by
Daniel Rosenwasser
parent
dc8a10ee99
commit
b0a985bf0b
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
9
tests/cases/fourslash/findAllRefsForStringLiteral2.ts
Normal file
9
tests/cases/fourslash/findAllRefsForStringLiteral2.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
// @filename: /a.ts
|
||||
/////**
|
||||
//// * @type {"foo" | "bar"}
|
||||
//// */
|
||||
////let x = "foo"/**/
|
||||
|
||||
verify.baselineFindAllReferences("");
|
||||
Reference in New Issue
Block a user