Skip to content

Emitted declarations for JS file do not import a class if it's re-exportedΒ #61718

Open
@keijokapp

Description

@keijokapp

πŸ”Ž Search Terms

import export class declarations

πŸ•— Version & Regression Information

This changed in PR #55472, commit 5ce34ca, version 5.3.0-dev.20230829.

⏯ Playground Link

No response

πŸ’» Code

index.js:

import { Something } from './something';
export { Something } from './something';

export const something = new Something();

something.ts (or something.js):

export class Something {}

tsconfig.json:

{
  "compilerOptions": {
    "checkJs": true,
    "declaration": true,
    "outDir": "dist"
  }
}

πŸ™ Actual behavior

The import of Something is missing in the emitted declarations file index.d.ts:

export { Something } from "./something";
export const something: Something;

πŸ™‚ Expected behavior

The import of Something should be included in the emitted declarations file index.d.ts:

export { Something } from "./something";
export const something: Something;
import { Something } from './something';

Additional information about the issue

The problem does not occur if

  • the file name is index.ts instead of index.js
  • export const something includes an explicit JSDoc type annotation (/** @type {Something} */)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions