Undocumented breaking change in 5.5.0-beta for reference directives
Jack-Works opened this issue ยท 3 comments
๐ 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
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
Sorry about that; it definitely was meant to be there in the blog! We'll get it updated.