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

Undocumented breaking change in 5.5.0-beta for reference directives #58324

Closed
Jack-Works opened this issue Apr 26, 2024 · 3 comments
Closed

Undocumented breaking change in 5.5.0-beta for reference directives #58324

Jack-Works opened this issue Apr 26, 2024 · 3 comments
Assignees
Labels
Docs The issue relates to how you learn TypeScript

Comments

@Jack-Works
Copy link
Contributor

πŸ”Ž Search Terms

5.5.0-beta

πŸ•— Version & Regression Information

  • This changed between versions 5.4 and 5.5

⏯ Playground Link

https://github.com/Jack-Works/reproduce

πŸ’» Code

Clone the repo

git clone https://github.com/Jack-Works/reproduce/ --filter=blob:none
cd reproduce/typescript-5.5-dts
pnpm install

pnpm run old
pnpm run new

πŸ™ Actual behavior

Global augmentation no longer works in 5.5.0-beta across different projects. (pnpm run new)

πŸ™‚ Expected behavior

Global augmentation works in 5.4 across different projects. (pnpm run old)

Additional information about the issue

Global augmentation across different projects is an important ability. Here are some examples:

  • You have a components project that augments the global JSX type, and you access those elements from another project
  • Theming a UI library
@robpalme
Copy link

robpalme commented Apr 26, 2024

Hello @Jack-Works, thanks for highlighting this. Your repro is using reference directives in the project's public-facing entrypoint module.

/// <reference path="./env.d.ts" />

It's true there is an intentional breaking change introduced by @jakebailey in the PR for Do not preserve references in declaration emit, unless preserve=true. And this is not yet documented in the TS 5.5 Beta announcement. so that post should be updated.

The intended workaround for cases where you want the reference directive included in the published declaration file is to add preserve=true.

/// <reference path="./env.d.ts" preserve=true/>

I'd suggest re-titling this issue:

Undocumented breaking change in 5.5.0-beta for reference directives

@Jack-Works Jack-Works changed the title Undocumented breaking change in 5.5.0-beta about module/global augmentation via .d.ts file across projects Undocumented breaking change in 5.5.0-beta for reference directives Apr 26, 2024
@RyanCavanaugh RyanCavanaugh added the Docs The issue relates to how you learn TypeScript label Apr 26, 2024
@jakebailey
Copy link
Member

Sorry about that; it definitely was meant to be there in the blog! We'll get it updated.

@jakebailey
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs The issue relates to how you learn TypeScript
Projects
None yet
Development

No branches or pull requests

4 participants