N
Nuxt7mo ago
Ragura

Vitest auto-import functions

Is there a way to correctly auto-import functions from Vitest, like it and expect while preserving their function types and not have them show as any? I got this far using the config, which generates the imports in the imports.d.ts file, but they still show up as any in the test files.
imports: {
imports: [
{
name: 'it, expect, describe, beforeEach, afterEach',
from: 'vitest',
},
],
},
imports: {
imports: [
{
name: 'it, expect, describe, beforeEach, afterEach',
from: 'vitest',
},
],
},
3 Replies
manniL
manniL7mo ago
Name only allows a single name as string presets: [ { from: 'vue', imports: [ 'ref', 'reactive', // ... ] } ] That works better
manniL
manniL7mo ago
GitHub
GitHub - unjs/unimport: Unified utils for auto importing APIs in mo...
Unified utils for auto importing APIs in modules. Contribute to unjs/unimport development by creating an account on GitHub.
Ragura
RaguraOP7mo ago
This works perfectly, thanks! Is this still fine to do if I'm using it inside a layer, and then the app that extends from the layer also has these auto-imported as part of its test setup, duplicating the types?
Want results from more Discord servers?
Add your server