Microsoft/TypeScript

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

Open

#61.718 aberto em 17 de mai. de 2025

Ver no GitHub
 (1 comment) (0 reactions) (0 assignees)TypeScript (6.726 forks)batch import
BugDomain: Declaration EmitHelp Wanted

Métricas do repositório

Stars
 (48.455 stars)
Métricas de merge de PR
 (Mesclagem média 6d 17h) (9 fundiu PRs em 30d)

Description

🔎 Search Terms

import export class declarations

🕗 Version & Regression Information

This changed in PR #55472, commit 5ce34cafad, 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} */)

Guia do colaborador