Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export type * ... statements in .d.ts files do not work (5.4 regression) #58304

Closed
Blckbrry-Pi opened this issue Apr 24, 2024 · 4 comments
Closed
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@Blckbrry-Pi
Copy link

Blckbrry-Pi commented Apr 24, 2024

πŸ”Ž Search Terms

"ts2339", "export *", ".d.ts", "regression", "5.4", "namespace", "Property does not exist"

πŸ•— Version & Regression Information

  • This changed between versions 5.3.3 and 5.4.2
  • Hasn't been fixed on nightly

⏯ Playground Link

(Just found out about Bug Workbench)

πŸ’» Code

Bug workbench

// @filename: orig.d.ts
export const moduleMember: "example";

// @filename: reexport.d.ts
export type * from "./orig.d.ts";

// @filename: consumer.ts
import * as Definitions from "./reexport.js";
console.log(Definitions.moduleMember); // Errors here on 5.4.2

Normal filesystem

orig.d.ts:

export const moduleMember: "example";

reexport.d.ts:

export type * from "./orig.d.ts";

consumer.ts:

import * as Definitions from "./reexport.js";
console.log(Definitions.moduleMember); // Errors here on 5.4.2+

πŸ™ Actual behavior

./node_modules/typescript-v5.3.3/bin/tsc --noEmit *.ts exited without errors

./node_modules/typescript-v5.4.2/bin/tsc --noEmit *.ts emitted error 2339:

consumer.ts:2:25 - error TS2339: Property 'moduleMember' does not exist on type 'typeof import("reexport")'.

2 console.log(Definitions.moduleMember); // Errors here on 5.4.2+
                          ~~~~~~~~~~~~

πŸ™‚ Expected behavior

./node_modules/typescript-v5.3.3/bin/tsc --noEmit *.ts to exit without errors

./node_modules/typescript-v5.4.2/bin/tsc --noEmit *.ts to exit without errors

Additional information about the issue

I was unable to build versions 5.4.0 and 5.4.1 with every-ts, and AFAIK, bug workbench doesn't support versions other than the most recent patch version.

This change may have happened by 5.4.0 or 5.4.1, but I know it definitely changed between 5.3.3 and 5.4.2.

@RyanCavanaugh
Copy link
Member

reexport says it's only exporting the types from orig, so it's correct to not re-export the values. That's the difference between export * and export type *.

@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Apr 25, 2024
@Blckbrry-Pi
Copy link
Author

Am I correct in saying that it does break backwards compatibility with Typescript 5.3.* if you were relying on export type * to behave like export * in a .d.ts file?

@RyanCavanaugh
Copy link
Member

Bug fixes can break compat, yes

@Blckbrry-Pi
Copy link
Author

Cool. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants