Skip to content
Permalink
Browse files
fix(50750): Object type literal with string literal property in conte…
…xtual 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
  • Loading branch information
a-tarasyuk committed Oct 3, 2022
1 parent 5cd49f6 commit 7dcf11f13985be927886ebea353d282a9b3418e0
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 0 deletions.
@@ -790,6 +790,8 @@ 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,52 @@
// === /a.ts ===
// interface Foo {
// property: /*FIND ALL REFS*/"[|foo|]";
// }
// /**
// * @type {{ property: "foo"}}
// */
// const obj: Foo = {
// property: "[|foo|]",
// }

[
{
"definition": {
"containerKind": "",
"containerName": "",
"fileName": "/a.ts",
"kind": "var",
"name": "foo",
"textSpan": {
"start": 31,
"length": 3
},
"displayParts": [
{
"text": "\"foo\"",
"kind": "stringLiteral"
}
]
},
"references": [
{
"textSpan": {
"start": 31,
"length": 3
},
"fileName": "/a.ts",
"isWriteAccess": false,
"isInString": true
},
{
"textSpan": {
"start": 111,
"length": 3
},
"fileName": "/a.ts",
"isWriteAccess": false,
"isInString": true
}
]
}
]
@@ -0,0 +1,11 @@
/*====== /a.ts ======*/

interface Foo {
property: "RENAME";
}
/**
* @type {{ property: "foo"}}
*/
const obj: Foo = {
property: "RENAME",
}
@@ -0,0 +1,14 @@
/// <reference path="fourslash.ts" />

// @filename: /a.ts
////interface Foo {
//// property: /**/"foo";
////}
/////**
//// * @type {{ property: "foo"}}
//// */
////const obj: Foo = {
//// property: "foo",
////}

verify.baselineFindAllReferences("");
@@ -0,0 +1,14 @@
/// <reference path="fourslash.ts" />

// @filename: /a.ts
////interface Foo {
//// property: /**/"foo";
////}
/////**
//// * @type {{ property: "foo"}}
//// */
////const obj: Foo = {
//// property: "foo",
////}

verify.baselineRename("", {});

0 comments on commit 7dcf11f

Please sign in to comment.