Visit typedef type expressions so they contribute to referenced-ness (#23525)
This commit is contained in:
parent
0526ff5fad
commit
557a34e897
|
@ -21865,6 +21865,11 @@ namespace ts {
|
|||
// If the node had `@property` tags, `typeExpression` would have been set to the first property tag.
|
||||
error(node.name, Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
|
||||
}
|
||||
|
||||
if (node.name) {
|
||||
checkTypeNameIsReserved(node.name, Diagnostics.Type_alias_name_cannot_be_0);
|
||||
}
|
||||
checkSourceElement(node.typeExpression);
|
||||
}
|
||||
|
||||
function checkJSDocParameterTag(node: JSDocParameterTag) {
|
||||
|
@ -24765,6 +24770,7 @@ namespace ts {
|
|||
case SyntaxKind.JSDocNullableType:
|
||||
case SyntaxKind.JSDocAllType:
|
||||
case SyntaxKind.JSDocUnknownType:
|
||||
case SyntaxKind.JSDocTypeLiteral:
|
||||
checkJSDocTypeIsInJsFile(node);
|
||||
forEachChild(node, checkSourceElement);
|
||||
return;
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
=== tests/cases/compiler/file.ts ===
|
||||
class Foo {
|
||||
>Foo : Symbol(Foo, Decl(file.ts, 0, 0))
|
||||
|
||||
x: number;
|
||||
>x : Symbol(Foo.x, Decl(file.ts, 0, 11))
|
||||
}
|
||||
|
||||
declare global {
|
||||
>global : Symbol(global, Decl(file.ts, 2, 1))
|
||||
|
||||
var module: any; // Just here to remove unrelated error from test
|
||||
>module : Symbol(module, Decl(file.ts, 5, 7))
|
||||
}
|
||||
|
||||
export = Foo;
|
||||
>Foo : Symbol(Foo, Decl(file.ts, 0, 0))
|
||||
|
||||
=== tests/cases/compiler/something.js ===
|
||||
/** @typedef {typeof import("./file")} Foo */
|
||||
|
||||
/** @typedef {(foo: Foo) => string} FooFun */
|
||||
|
||||
module.exports = /** @type {FooFun} */(void 0);
|
||||
>module : Symbol(export=, Decl(something.js, 0, 0))
|
||||
>exports : Symbol(export=, Decl(something.js, 0, 0))
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
=== tests/cases/compiler/file.ts ===
|
||||
class Foo {
|
||||
>Foo : Foo
|
||||
|
||||
x: number;
|
||||
>x : number
|
||||
}
|
||||
|
||||
declare global {
|
||||
>global : typeof global
|
||||
|
||||
var module: any; // Just here to remove unrelated error from test
|
||||
>module : any
|
||||
}
|
||||
|
||||
export = Foo;
|
||||
>Foo : Foo
|
||||
|
||||
=== tests/cases/compiler/something.js ===
|
||||
/** @typedef {typeof import("./file")} Foo */
|
||||
|
||||
/** @typedef {(foo: Foo) => string} FooFun */
|
||||
|
||||
module.exports = /** @type {FooFun} */(void 0);
|
||||
>module.exports = /** @type {FooFun} */(void 0) : (foo: typeof Foo) => string
|
||||
>module.exports : any
|
||||
>module : any
|
||||
>exports : any
|
||||
>(void 0) : (foo: typeof Foo) => string
|
||||
>void 0 : undefined
|
||||
>0 : 0
|
||||
|
20
tests/cases/compiler/checkJsTypeDefNoUnusedLocalMarked.ts
Normal file
20
tests/cases/compiler/checkJsTypeDefNoUnusedLocalMarked.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
// @allowJs: true
|
||||
// @checkJs: true
|
||||
// @noEmit: true
|
||||
// @noUnusedLocals: true
|
||||
// @filename: file.ts
|
||||
class Foo {
|
||||
x: number;
|
||||
}
|
||||
|
||||
declare global {
|
||||
var module: any; // Just here to remove unrelated error from test
|
||||
}
|
||||
|
||||
export = Foo;
|
||||
// @filename: something.js
|
||||
/** @typedef {typeof import("./file")} Foo */
|
||||
|
||||
/** @typedef {(foo: Foo) => string} FooFun */
|
||||
|
||||
module.exports = /** @type {FooFun} */(void 0);
|
Loading…
Reference in a new issue