nitro icon indicating copy to clipboard operation
nitro copied to clipboard

auto-imported utils are not added to `nitro.d.ts`

Open danielroe opened this issue 1 year ago • 1 comments

Environment

latest stackblitz

Reproduction

https://stackblitz.com/edit/github-cwdzfl-he3tmt

Describe the bug

Any dynamic auto-imports that are added via modifyDynamicImports are not included in nitro.d.ts so we don't get type help for them:

https://github.com/unjs/nitropack/blob/0f241bc9541c7369433d7e45b5641ff023c02e1d/src/build.ts#L60-L66

(If trying in stackblitz you can run cat .nitro/types/nitro.d.ts to see the auto-generated types.)

At the moment unimport doesn't have ability to write these dynamic types: https://github.com/unjs/unimport/blob/aa75ae2ac1eb1b1d0f2f895e900117ad217d06de/src/context.ts#L80 (cc: @antfu)

But even if we change that line to [...ctx.imports, ...ctx.dynamicImports], we still face the issue that by the time it's initially called, the additional auto-imports have not yet been resolved and couldn't be written to nitro.d.ts.

Additional context

No response

Logs

No response

danielroe avatar Aug 29 '22 11:08 danielroe