-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Description
🔎 Search Terms
augmentation
export
augmentation type implicit import
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about augmentation.
I couldn't find any FAQ entries about augmentation.
Among others, I tried 5.9.3, the current nightly, and 4.5.5.
⏯ Playground Link
💻 Code
declare module 'example' {
export type DirectlyExported = unknown
type IndirectlyExported = unknown
export { type IndirectlyExported }
}
declare module 'example' {
type Works = DirectlyExported
type DoesNotWork = IndirectlyExported
// ^^^^^^^^^^^^^^^^^^
// Cannot find name 'IndirectlyExported'.
}🙁 Actual behavior
There's an inconsistency between export type and export { type }. The latter doesn't seem to allow augmentations to access the type.
🙂 Expected behavior
export { type } should behave like export type for augmentations.
Additional information about the issue
I initially asked about this on the TypeScript Discord, https://discord.com/channels/508357248330760243/1466086808231350531. The Playground I shared above was suggested by someone in the discussion there, as my original example needed multiple files.
The background is that I'm trying to migrate a library from Rollup to Rolldown. The types generated by the existing Rollup build look a bit like this in the .d.ts file:
export declare type Foo = 'A';
export {}The new Rolldown build is generating this:
type Foo = 'A';
export { type Foo };These are then used in the consuming application to augment the types of the library, e.g.:
declare module 'library-name' {
export interface Baz {
bar: Foo
}
}
export {}With the first .d.ts file this works fine, but with the second .d.ts file the type Foo needs to be explicitly imported.
If TypeScript is working as intended then this may need changes to the d.ts generation in Rolldown.