Skip to content

Support @typedef importing a CommonJS default exported class as type into another fileΒ #23375

Closed
@TheLarkInn

Description

@TheLarkInn

TypeScript Version: 2.9.0-dev.20180412

Search Terms: import("./") jsdoc JavaScript TypeScript CommonJs

Code
https://github.com/webpack/webpack/blob/10282ea20648b465caec6448849f24fc34e1ba3e/lib/Chunk.js#L477 Chunk.js

module.exports = Chunk; // Chunk is a class as seen linked above
/**
 * @typedef { import("./Chunk.js") } Chunk
 */

// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.

Expected behavior:
No error, and that the Class is a Type that can be referenced.
Actual behavior:

lib/ChunkGroup.js:8:15 - error TS1340: Module './Chunk.js' does not refer to a type, but is used as a type here.

* @typedef { import("./Chunk.js") } Chunk

Playground Link:
Not possible because this is across two separate CommonJS modules.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions