You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
publishing deep-dive is out of date regarding "exports" #3088
changed the title [-]publisihng deep-dive is out of date regarding "exports"[/-][+]publishing deep-dive is out of date regarding "exports"[/+]on May 5, 2024
Indeed, if you have exports, you must define types inside of exports (e.g. exports.types). Per TS maintainers in microsoft/TypeScript#52363 (comment) and microsoft/TypeScript#46334, TS will not fallback to the top-level types when exports is defined. Those maintainer comments have been referenced a lot and are buried in TS issues -- there really should be clear, direct, official guidance in the official docs.
One of the maintainers also created https://github.com/arethetypeswrong/arethetypeswrong.github.io as a website and CLI to diagnose this -- would be nice to add that to the docs too.
Matching the intent of the "Publishing" page, I think specific, centralized publishing guidance would be better and would significantly reduce confusion.
I tested this and typings does not work inside of exports. You cannot use exports.typings and must use exports.types (or deeper structures -- the naming is the key difference, literally).
As such, for consistency and less mistakes, it would make sense to migrate top-level typings to types as well and only mention this as a legacy alias that should not be used moving forward.
a short section on "exports", showing the "types" condition listed first for each subpath, and that under node16, nodenext and bundler resolution TypeScript doesn't fall back to the top-level "types" for paths that "exports" covers
"typings" presented as a legacy field that doesn't work as a condition inside "exports"
links to the modules reference, the 4.7 release notes and arethetypeswrong
Updated, docs? Yes, please.
I think the note that "types" is required is mistaken, though. TypeScript, in my experience, will look for a .d.ts in same location as .js when "types" condition isn't resolved first. It is nice simplification for package authors to just specify the runtime .js path for exports entry when .d.ts is expected sibling rather than necessarily having "types" qualification.
Ah, good catch, you're right! If the .d.ts sits right next to the .js, TypeScript finds it on its own, so "types" is only needed when the declarations live somewhere else.
Activity
[-]publisihng deep-dive is out of date regarding "exports"[/-][+]publishing deep-dive is out of date regarding "exports"[/+]agilgur5 commentedon Mar 24, 2025
The lack of updates on this page is indeed very confusing for library developers. Just ran into this issue twice in taybenlor/runno#324 and agilgur5/react-signature-canvas#126.
Indeed, if you have
exports, you must definetypesinside ofexports(e.g.exports.types). Per TS maintainers in microsoft/TypeScript#52363 (comment) and microsoft/TypeScript#46334, TS will not fallback to the top-leveltypeswhenexportsis defined. Those maintainer comments have been referenced a lot and are buried in TS issues -- there really should be clear, direct, official guidance in the official docs.One of the maintainers also created https://github.com/arethetypeswrong/arethetypeswrong.github.io as a website and CLI to diagnose this -- would be nice to add that to the docs too.
There are also some docs buried in the 4.7 release notes.
Matching the intent of the "Publishing" page, I think specific, centralized publishing guidance would be better and would significantly reduce confusion.
I tested this and
typingsdoes not work inside ofexports. You cannot useexports.typingsand must useexports.types(or deeper structures -- the naming is the key difference, literally).As such, for consistency and less mistakes, it would make sense to migrate top-level
typingstotypesas well and only mention this as a legacy alias that should not be used moving forward.MartinFerret commentedon Nov 14, 2026
I'd like to pick this up, building on Anton Gilgur (@agilgur5)'s notes above.
My plan for Publishing.md:
WDYT?
jason-ha commentedon Nov 16, 2026
Updated, docs? Yes, please.
I think the note that "types" is required is mistaken, though. TypeScript, in my experience, will look for a
.d.tsin same location as.jswhen "types" condition isn't resolved first. It is nice simplification for package authors to just specify the runtime .js path for exports entry when .d.ts is expected sibling rather than necessarily having "types" qualification.MartinFerret commentedon Nov 16, 2026
Ah, good catch, you're right! If the .d.ts sits right next to the .js, TypeScript finds it on its own, so "types" is only needed when the declarations live somewhere else.
I'll make that clear in the docs. Thanks!
MartinFerret commentedon Nov 26, 2026
#3708 covers this now, so I'll step back. Thanks!