Skip to content

Commit

Permalink
refactor: typing ExecuteOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Oct 3, 2024
1 parent 0ce26a4 commit 2447160
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/vitest/src/public/execute.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { VitestExecutor } from '../runtime/execute'
export { VitestExecutor, ExecuteOptions } from '../runtime/execute'
3 changes: 2 additions & 1 deletion packages/web-worker/src/runner.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { ExecuteOptions } from 'vitest/execute'
import { VitestExecutor } from 'vitest/execute'

export class InlineWorkerRunner extends VitestExecutor {
constructor(options: any, private context: any) {
constructor(options: ExecuteOptions, private context: any) {
super(options)
}

Expand Down
2 changes: 1 addition & 1 deletion packages/web-worker/src/shared-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function createSharedWorkerConstructor(): typeof SharedWorker {

return runner.executeFile(fsPath).then(() => {
// worker should be new every time, invalidate its sub dependency
runnerOptions.moduleCache.invalidateSubDepTree([
runnerOptions.moduleCache!.invalidateSubDepTree([
fsPath,
runner.mocker.getMockPath(fsPath),
])
Expand Down
3 changes: 2 additions & 1 deletion packages/web-worker/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { readFileSync as _readFileSync } from 'node:fs'
import type { WorkerGlobalState } from 'vitest'
import ponyfillStructuredClone from '@ungap/structured-clone'
import createDebug from 'debug'
import type { ExecuteOptions } from 'vitest/execute'
import type { CloneOption } from './types'

// keep the reference in case it was mocked
Expand Down Expand Up @@ -79,7 +80,7 @@ export function createMessageEvent(
}
}

export function getRunnerOptions(): any {
export function getRunnerOptions(): ExecuteOptions {
const state = getWorkerState()
const { config, rpc, moduleCache } = state

Expand Down
2 changes: 1 addition & 1 deletion packages/web-worker/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function createWorkerConstructor(

return runner.executeFile(fsPath).then(() => {
// worker should be new every time, invalidate its sub dependency
runnerOptions.moduleCache.invalidateSubDepTree([
runnerOptions.moduleCache!.invalidateSubDepTree([
fsPath,
runner.mocker.getMockPath(fsPath),
])
Expand Down

0 comments on commit 2447160

Please sign in to comment.