Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
getTypeFromJSDocValueReference: handle import types
Previously it only handled types whose declaration was from `require`, but now it handles types whose reference is an import type as well.
- Loading branch information
Showing
4 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
tests/baselines/reference/jsdocImportTypeReferenceToClassAlias.symbols
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
=== tests/cases/conformance/jsdoc/mod1.js === | ||
class C { | ||
>C : Symbol(C, Decl(mod1.js, 0, 0)) | ||
|
||
s() { } | ||
>s : Symbol(C.s, Decl(mod1.js, 0, 9)) | ||
} | ||
module.exports.C = C | ||
>module.exports.C : Symbol(C, Decl(mod1.js, 2, 1)) | ||
>module.exports : Symbol(C, Decl(mod1.js, 2, 1)) | ||
>module : Symbol(module, Decl(mod1.js, 2, 1)) | ||
>exports : Symbol("tests/cases/conformance/jsdoc/mod1", Decl(mod1.js, 0, 0)) | ||
>C : Symbol(C, Decl(mod1.js, 2, 1)) | ||
>C : Symbol(C, Decl(mod1.js, 0, 0)) | ||
|
||
=== tests/cases/conformance/jsdoc/test.js === | ||
/** @typedef {import('./mod1').C} X */ | ||
/** @param {X} c */ | ||
function demo(c) { | ||
>demo : Symbol(demo, Decl(test.js, 0, 0)) | ||
>c : Symbol(c, Decl(test.js, 2, 14)) | ||
|
||
c.s | ||
>c.s : Symbol(C.s, Decl(mod1.js, 0, 9)) | ||
>c : Symbol(c, Decl(test.js, 2, 14)) | ||
>s : Symbol(C.s, Decl(mod1.js, 0, 9)) | ||
} | ||
|
29 changes: 29 additions & 0 deletions
29
tests/baselines/reference/jsdocImportTypeReferenceToClassAlias.types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
=== tests/cases/conformance/jsdoc/mod1.js === | ||
class C { | ||
>C : C | ||
|
||
s() { } | ||
>s : () => void | ||
} | ||
module.exports.C = C | ||
>module.exports.C = C : typeof C | ||
>module.exports.C : typeof C | ||
>module.exports : typeof import("tests/cases/conformance/jsdoc/mod1") | ||
>module : { "tests/cases/conformance/jsdoc/mod1": typeof import("tests/cases/conformance/jsdoc/mod1"); } | ||
>exports : typeof import("tests/cases/conformance/jsdoc/mod1") | ||
>C : typeof C | ||
>C : typeof C | ||
|
||
=== tests/cases/conformance/jsdoc/test.js === | ||
/** @typedef {import('./mod1').C} X */ | ||
/** @param {X} c */ | ||
function demo(c) { | ||
>demo : (c: C) => void | ||
>c : C | ||
|
||
c.s | ||
>c.s : () => void | ||
>c : C | ||
>s : () => void | ||
} | ||
|
15 changes: 15 additions & 0 deletions
15
tests/cases/conformance/jsdoc/jsdocImportTypeReferenceToClassAlias.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// @noEmit: true | ||
// @allowJs: true | ||
// @checkJs: true | ||
// @Filename: mod1.js | ||
class C { | ||
s() { } | ||
} | ||
module.exports.C = C | ||
|
||
// @Filename: test.js | ||
/** @typedef {import('./mod1').C} X */ | ||
/** @param {X} c */ | ||
function demo(c) { | ||
c.s | ||
} |