microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
98.27k stars 12.2k forks source link

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

Closed Jack-Works closed 2 weeks ago

Jack-Works commented 2 weeks ago

🔎 Search Terms

5.5.0-beta

🕗 Version & Regression Information

⏯ 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:

robpalme commented 2 weeks ago

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

jakebailey commented 2 weeks ago

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

jakebailey commented 2 weeks ago

Blog post has been updated: https://devblogs.microsoft.com/typescript/announcing-typescript-5-5-beta/#simplified-reference-directive-declaration-emit