Affected package
@types/luxon (3.7.0 and later, reproduced on 3.7.5)
Summary
The validity helper types Valid, Invalid and DefaultValidity live in src/_util.d.ts, which is not re-exported from the barrel (src/luxon.d.ts). Before 3.7.0 they could still be reached with import type { Valid } from 'luxon/src/_util'. Since #73292 added an exports map to fix arethetypeswrong, that subpath no longer resolves, and there is now no way to name these types.
That matters because they are the type arguments of public generics: DateTime<IsValid>, Interval<IsValid>, Duration<IsValid> and Zone<IsValid> are all exported, but the values their parameter accepts are not.
Reproduction
// @types/luxon 3.7.5, luxon 3.7.2, TypeScript 5.9.3, moduleResolution: bundler
import type { DateTime } from 'luxon'
import type { DefaultValidity, Invalid, Valid } from 'luxon/src/_util'
// ^ TS2307: Cannot find module 'luxon/src/_util'
// or its corresponding type declarations.
export type Range = { start: DateTime<Valid>, end: DateTime<Valid> }
Other spellings are also closed:
'@types/luxon/src/_util' — TS6137: Cannot import type declaration files. (and @types/luxon has its own exports map limited to . and ./package.json)
- Suppressing with
@ts-expect-error compiles, but the imported names become any, which silently degrades DateTime<Valid> | DateTime<Invalid> to a single DateTime<any> and loses the narrowing the generics exist to provide.
Workarounds that do exist
For most call sites the public API is enough, and arguably reads better:
DateTime<Valid> → DateTime<true> (Valid is declared as true)
DateTime<Valid> | DateTime<Invalid> → the exported DateTimeMaybeValid
DateTime<DefaultValidity> → plain DateTime, since DefaultValidity is the declared default
DefaultValidity itself has no public equivalent. It can be recovered by inference:
type DefaultValidity = DateTime extends DateTime<infer V> ? V : never
but that is a workaround for a name the package could simply export.
Suggested fix
Re-export the helpers from the barrel so they are nameable, for example in src/luxon.d.ts:
export type { CanBeInvalid, DefaultValidity, IfValid, Invalid, Valid } from "./_util";
Adding "./src/*" to the exports map would also work, but re-exporting keeps the ATTW fix intact and does not expose the rest of the internals.
Happy to open a PR for whichever shape maintainers prefer.
Affected package
@types/luxon(3.7.0 and later, reproduced on 3.7.5)Summary
The validity helper types
Valid,InvalidandDefaultValiditylive insrc/_util.d.ts, which is not re-exported from the barrel (src/luxon.d.ts). Before 3.7.0 they could still be reached withimport type { Valid } from 'luxon/src/_util'. Since #73292 added anexportsmap to fixarethetypeswrong, that subpath no longer resolves, and there is now no way to name these types.That matters because they are the type arguments of public generics:
DateTime<IsValid>,Interval<IsValid>,Duration<IsValid>andZone<IsValid>are all exported, but the values their parameter accepts are not.Reproduction
Other spellings are also closed:
'@types/luxon/src/_util'—TS6137: Cannot import type declaration files.(and@types/luxonhas its ownexportsmap limited to.and./package.json)@ts-expect-errorcompiles, but the imported names becomeany, which silently degradesDateTime<Valid> | DateTime<Invalid>to a singleDateTime<any>and loses the narrowing the generics exist to provide.Workarounds that do exist
For most call sites the public API is enough, and arguably reads better:
DateTime<Valid>→DateTime<true>(Validis declared astrue)DateTime<Valid> | DateTime<Invalid>→ the exportedDateTimeMaybeValidDateTime<DefaultValidity>→ plainDateTime, sinceDefaultValidityis the declared defaultDefaultValidityitself has no public equivalent. It can be recovered by inference:but that is a workaround for a name the package could simply export.
Suggested fix
Re-export the helpers from the barrel so they are nameable, for example in
src/luxon.d.ts:Adding
"./src/*"to theexportsmap would also work, but re-exporting keeps the ATTW fix intact and does not expose the rest of the internals.Happy to open a PR for whichever shape maintainers prefer.