@@ -11,13 +11,14 @@ import { readFile } from 'node:fs/promises';
1111import { createRequire } from 'node:module' ;
1212import { platform } from 'node:os' ;
1313import path from 'node:path' ;
14-
1514import type {
1615 BrowserConfigOptions ,
1716 InlineConfig ,
1817 ResolvedConfig ,
1918 UserWorkspaceConfig ,
19+ Vite ,
2020 VitestPlugin ,
21+ VitestPluginContext ,
2122} from 'vitest/node' ;
2223import { createBuildAssetsMiddleware } from '../../../../tools/vite/middlewares/assets-middleware' ;
2324import { toPosixPath } from '../../../../utils/path' ;
@@ -50,7 +51,7 @@ interface VitestConfigPluginOptions {
5051 projectSourceRoot : string ;
5152 reporters ?: string [ ] | [ string , object ] [ ] ;
5253 setupFiles : string [ ] ;
53- projectPlugins : Exclude < UserWorkspaceConfig [ 'plugins' ] , undefined > ;
54+ projectPlugins : Vite . PluginOption [ ] ;
5455 include : string [ ] ;
5556 optimizeDepsInclude : string [ ] ;
5657 watch : boolean ;
@@ -162,7 +163,7 @@ export async function createVitestConfigPlugin(
162163
163164 return {
164165 name : 'angular:vitest-configuration' ,
165- async config ( config ) {
166+ async config ( config : UserWorkspaceConfig & Vite . UserConfig ) {
166167 const testConfig = config . test ;
167168
168169 const determinedProvider = determineCoverageProvider (
@@ -219,7 +220,7 @@ export async function createVitestConfigPlugin(
219220 // Merge user-defined plugins from the Vitest config with the CLI's internal plugins.
220221 if ( config . plugins ) {
221222 const userPlugins = config . plugins . filter (
222- ( plugin ) =>
223+ ( plugin : Vite . PluginOption ) =>
223224 // Only inspect objects with a `name` property as these would be the internal injected plugins
224225 ! plugin ||
225226 typeof plugin !== 'object' ||
@@ -243,7 +244,7 @@ export async function createVitestConfigPlugin(
243244
244245 const projectResolver = createRequire ( projectSourceRoot + '/' ) . resolve ;
245246
246- const projectDefaults : UserWorkspaceConfig = {
247+ const projectDefaults : Vite . UserConfig & UserWorkspaceConfig = {
247248 test : {
248249 setupFiles,
249250 globals : true ,
@@ -262,7 +263,7 @@ export async function createVitestConfigPlugin(
262263 } ;
263264
264265 const { optimizeDeps, resolve } = config ;
265- const projectOverrides : UserWorkspaceConfig = {
266+ const projectOverrides : Vite . UserConfig & UserWorkspaceConfig = {
266267 test : {
267268 name : projectName ,
268269 include,
@@ -291,8 +292,7 @@ export async function createVitestConfigPlugin(
291292 projectName ,
292293 determinedProvider ,
293294 ) ,
294- // eslint-disable-next-line @typescript-eslint/no-explicit-any
295- ...( reporters ? ( { reporters } as any ) : { } ) ,
295+ ...( reporters ? { reporters } : { } ) ,
296296 projects : [ projectConfig ] ,
297297 } ,
298298 } ;
@@ -318,10 +318,10 @@ export function createVitestPlugins(pluginOptions: PluginOptions): VitestPlugins
318318 {
319319 name : 'angular:test-in-memory-provider' ,
320320 enforce : 'pre' ,
321- configureVitest ( context ) {
321+ configureVitest ( context : VitestPluginContext ) {
322322 vitestConfig = context . vitest . config ;
323323 } ,
324- resolveId : ( id , importer ) => {
324+ resolveId : ( id : string , importer : string | undefined ) => {
325325 // Fast path for test entry points.
326326 if ( testFileToEntryPoint . has ( id ) ) {
327327 return id ;
@@ -375,7 +375,7 @@ export function createVitestPlugins(pluginOptions: PluginOptions): VitestPlugins
375375 // If the module cannot be resolved from the build artifacts, let other plugins handle it.
376376 return undefined ;
377377 } ,
378- async load ( id ) {
378+ async load ( id : string ) {
379379 assert ( buildResultFiles . size > 0 , 'buildResult must be available for in-memory loading.' ) ;
380380
381381 // Attempt to load as a source test file.
@@ -416,7 +416,7 @@ export function createVitestPlugins(pluginOptions: PluginOptions): VitestPlugins
416416 } ;
417417 }
418418 } ,
419- configureServer : ( server ) => {
419+ configureServer : ( server : Vite . ViteDevServer ) => {
420420 server . middlewares . use ( createBuildAssetsMiddleware ( server . config . base , buildResultFiles ) ) ;
421421 } ,
422422 } ,
0 commit comments