Skip to content

Commit 7dcf11f

Browse files
authoredOct 3, 2022
fix(50750): Object type literal with string literal property in contextual typing position causes language service error on all literal type references (#50757)
* fix(50750): skip unbound symbols from JSDoc tags in typescript * skip contextual type checking in JsDoc for TypeScript files
1 parent 5cd49f6 commit 7dcf11f

File tree

5 files changed

+93
-0
lines changed

5 files changed

+93
-0
lines changed
 

‎src/services/utilities.ts

+2
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,8 @@ 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+
793795
const contextualType = getContextualTypeFromParent(node, checker);
794796
if (contextualType) return contextualType;
795797

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// === /a.ts ===
2+
// interface Foo {
3+
// property: /*FIND ALL REFS*/"[|foo|]";
4+
// }
5+
// /**
6+
// * @type {{ property: "foo"}}
7+
// */
8+
// const obj: Foo = {
9+
// property: "[|foo|]",
10+
// }
11+
12+
[
13+
{
14+
"definition": {
15+
"containerKind": "",
16+
"containerName": "",
17+
"fileName": "/a.ts",
18+
"kind": "var",
19+
"name": "foo",
20+
"textSpan": {
21+
"start": 31,
22+
"length": 3
23+
},
24+
"displayParts": [
25+
{
26+
"text": "\"foo\"",
27+
"kind": "stringLiteral"
28+
}
29+
]
30+
},
31+
"references": [
32+
{
33+
"textSpan": {
34+
"start": 31,
35+
"length": 3
36+
},
37+
"fileName": "/a.ts",
38+
"isWriteAccess": false,
39+
"isInString": true
40+
},
41+
{
42+
"textSpan": {
43+
"start": 111,
44+
"length": 3
45+
},
46+
"fileName": "/a.ts",
47+
"isWriteAccess": false,
48+
"isInString": true
49+
}
50+
]
51+
}
52+
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*====== /a.ts ======*/
2+
3+
interface Foo {
4+
property: "RENAME";
5+
}
6+
/**
7+
* @type {{ property: "foo"}}
8+
*/
9+
const obj: Foo = {
10+
property: "RENAME",
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @filename: /a.ts
4+
////interface Foo {
5+
//// property: /**/"foo";
6+
////}
7+
/////**
8+
//// * @type {{ property: "foo"}}
9+
//// */
10+
////const obj: Foo = {
11+
//// property: "foo",
12+
////}
13+
14+
verify.baselineFindAllReferences("");
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/// <reference path="fourslash.ts" />
2+
3+
// @filename: /a.ts
4+
////interface Foo {
5+
//// property: /**/"foo";
6+
////}
7+
/////**
8+
//// * @type {{ property: "foo"}}
9+
//// */
10+
////const obj: Foo = {
11+
//// property: "foo",
12+
////}
13+
14+
verify.baselineRename("", {});

0 commit comments

Comments
 (0)
Please sign in to comment.