@@ -55,7 +55,8 @@ export const createMockPlugin = (ctx: MockPluginContext) => createUnplugin(() =>
5555 const mocksComponent : MockComponentInfo [ ] = [ ]
5656 const importPathsList : Set < string > = new Set ( )
5757
58- walk ( ast as any , {
58+ // @ts -expect-error mismatch between acorn/estree types
59+ walk ( ast , {
5960 enter : ( node , parent ) => {
6061 // find existing vi import
6162 if ( isImportDeclaration ( node ) ) {
@@ -259,7 +260,7 @@ export const createMockPlugin = (ctx: MockPluginContext) => createUnplugin(() =>
259260 const plugins = ( config . plugins || [ ] ) as Plugin [ ]
260261
261262 // `vite:mocks` was a typo in Vitest before v0.34.0
262- const vitestPlugins = plugins . filter ( p => ( p . name === 'vite:mocks' || p . name . startsWith ( 'vitest:' ) ) && ( p . enforce || ( p as any ) . order ) === 'post' )
263+ const vitestPlugins = plugins . filter ( p => ( p . name === 'vite:mocks' || p . name . startsWith ( 'vitest:' ) ) && ( p . enforce || ( 'order' in p && p . order === 'post' ) ) )
263264 const lastNuxt = findLastIndex (
264265 plugins ,
265266 i => i . name ?. startsWith ( 'nuxt:' ) ,
@@ -305,8 +306,8 @@ function isExpressionStatement(node: Node | null): node is ExpressionStatement {
305306}
306307// TODO: need to fix in rollup types, probably
307308function startOf ( node : Node ) {
308- return 'range' in node && node . range ? node . range [ 0 ] : ( node as any ) . start as number
309+ return 'range' in node && node . range ? node . range [ 0 ] : ( 'start' in node ? node . start as number : undefined as never )
309310}
310311function endOf ( node : Node ) {
311- return 'range' in node && node . range ? node . range [ 1 ] : ( node as any ) . end as number
312+ return 'range' in node && node . range ? node . range [ 1 ] : ( 'end' in node ? node . end as number : undefined as never )
312313}
0 commit comments