Skip to content

Commit 5941c6e

Browse files
authored
Emit an any for namepath types (#37176)
1 parent ab8adc5 commit 5941c6e

File tree

5 files changed

+105
-1
lines changed

5 files changed

+105
-1
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6331,7 +6331,8 @@ namespace ts {
63316331
return result;
63326332

63336333
function visitExistingNodeTreeSymbols<T extends Node>(node: T): Node {
6334-
if (isJSDocAllType(node)) {
6334+
// We don't _actually_ support jsdoc namepath types, emit `any` instead
6335+
if (isJSDocAllType(node) || node.kind === SyntaxKind.JSDocNamepathType) {
63356336
return createKeywordTypeNode(SyntaxKind.AnyKeyword);
63366337
}
63376338
if (isJSDocUnknownType(node)) {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//// [index.js]
2+
/**
3+
* @module A
4+
*/
5+
class A {}
6+
7+
8+
/**
9+
* Target element
10+
* @type {module:A}
11+
*/
12+
export let el = null;
13+
14+
export default A;
15+
16+
//// [index.js]
17+
"use strict";
18+
Object.defineProperty(exports, "__esModule", { value: true });
19+
exports.el = void 0;
20+
/**
21+
* @module A
22+
*/
23+
var A = /** @class */ (function () {
24+
function A() {
25+
}
26+
return A;
27+
}());
28+
/**
29+
* Target element
30+
* @type {module:A}
31+
*/
32+
exports.el = null;
33+
exports.default = A;
34+
35+
36+
//// [index.d.ts]
37+
/**
38+
* Target element
39+
* @type {module:A}
40+
*/
41+
export let el: any;
42+
export default A;
43+
/**
44+
* @module A
45+
*/
46+
declare class A {
47+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
=== tests/cases/conformance/jsdoc/declarations/index.js ===
2+
/**
3+
* @module A
4+
*/
5+
class A {}
6+
>A : Symbol(A, Decl(index.js, 0, 0))
7+
8+
9+
/**
10+
* Target element
11+
* @type {module:A}
12+
*/
13+
export let el = null;
14+
>el : Symbol(el, Decl(index.js, 10, 10))
15+
16+
export default A;
17+
>A : Symbol(A, Decl(index.js, 0, 0))
18+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
=== tests/cases/conformance/jsdoc/declarations/index.js ===
2+
/**
3+
* @module A
4+
*/
5+
class A {}
6+
>A : A
7+
8+
9+
/**
10+
* Target element
11+
* @type {module:A}
12+
*/
13+
export let el = null;
14+
>el : error
15+
>null : null
16+
17+
export default A;
18+
>A : A
19+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// @allowJs: true
2+
// @checkJs: true
3+
// @target: es5
4+
// @outDir: ./out
5+
// @declaration: true
6+
// @filename: index.js
7+
/**
8+
* @module A
9+
*/
10+
class A {}
11+
12+
13+
/**
14+
* Target element
15+
* @type {module:A}
16+
*/
17+
export let el = null;
18+
19+
export default A;

0 commit comments

Comments
 (0)