When a file only contains global declarations, it is not auto-imported
Environment
unimport: 5.0.0 node: 22.14
Reproduction
https://stackblitz.com/edit/github-av9ljigg?file=.nuxt%2Ftypes%2Fimports.d.ts
After the project is installed and the dev server has started, go to file .nuxt/types/imports.d.ts.
Describe the bug
When a file only contains declare global, but does not contain any type exports or regular exports, the file is skipped during auto-import. As soon as a regular or type export is added to that file, it is auto-imported and the global declaration becomes available in the type layer of the app.
Repro explanation
In the repro, which is a basic Nuxt project setup, I manually auto-import the following three files:
1. a.ts
export const a = 'a';
export type A = typeof a;
2. b.ts
export const b = 'b';
declare global {
type B = typeof b;
}
3. c.ts
export {};
declare global {
type C = 'C';
}
This has the following effect on .nuxt/types/imports.d.ts (irrelevant stuff is left out):
// Generated by auto imports
export {}
declare global {
const a: typeof import('../../extra/a')['a']
const b: typeof import('../../extra/b')['b']
}
// for type re-export
declare global {
// @ts-ignore
export type { A } from '../../extra/a'
import('../../extra/a')
}
import { UnwrapRef } from 'vue'
declare module 'vue' {
interface ComponentCustomProperties {
readonly a: UnwrapRef<typeof import('../../extra/a')['a']>
readonly b: UnwrapRef<typeof import('../../extra/b')['b']>
}
}
As you can see, c.ts is entirely ignored, while global declarations of b.ts are included, because it contains a regular export.
Additional context
No response
Logs
Just curious, should they be auto-imported? If they are global, they should be usable directly, even without importing.
Your repro seems to work fine for me. What do you expect? The c.ts does not export any thing soi it's not included - which is working as expected
Edited: I expected c.ts to be auto-imported too. If the original file is not included in the tsconfig of the app (in include), the globally declared type is not available in the app. Therefore, I would expect auto-import to add the file to the generated .d.ts file.