Skip to content

Commit 89a1cb6

Browse files
authored
fix!: remove deprecated typecheck and runner types (#8199)
1 parent 4703cf8 commit 89a1cb6

File tree

8 files changed

+34
-79
lines changed

8 files changed

+34
-79
lines changed

packages/ui/client/components/views/ViewReport.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { File } from 'vitest'
1+
import type { RunnerTestFile } from 'vitest'
22
import { faker } from '@faker-js/faker'
33
import { beforeEach, describe, expect, it } from 'vitest'
44
import { config } from '~/composables/client'
@@ -42,7 +42,7 @@ const error = {
4242
diff,
4343
}
4444

45-
const fileWithTextStacks: File = {
45+
const fileWithTextStacks: RunnerTestFile = {
4646
id: 'f-1',
4747
name: 'test/plain-stack-trace.ts',
4848
type: 'suite',
@@ -60,7 +60,7 @@ const fileWithTextStacks: File = {
6060
fileWithTextStacks.file = fileWithTextStacks
6161

6262
describe('ViewReport', () => {
63-
describe('File where stacks are in text', () => {
63+
describe('RunnerTestFile where stacks are in text', () => {
6464
beforeEach(() => {
6565
render(ViewReport, {
6666
props: {
@@ -92,7 +92,7 @@ describe('ViewReport', () => {
9292
})
9393

9494
it('test html stack trace without html message', () => {
95-
const file: File = {
95+
const file: RunnerTestFile = {
9696
id: 'f-1',
9797
name: 'test/plain-stack-trace.ts',
9898
type: 'suite',
@@ -150,7 +150,7 @@ describe('ViewReport', () => {
150150
})
151151

152152
it('test html stack trace and message', () => {
153-
const file: File = {
153+
const file: RunnerTestFile = {
154154
id: 'f-1',
155155
name: 'test/plain-stack-trace.ts',
156156
type: 'suite',

packages/ui/client/composables/client/index.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import type { WebSocketStatus } from '@vueuse/core'
2-
import type { File, RunnerTaskEventPack, SerializedConfig, Task, TaskResultPack, TestAnnotation } from 'vitest'
2+
import type {
3+
RunnerTask,
4+
RunnerTaskEventPack,
5+
RunnerTaskResultPack,
6+
RunnerTestFile,
7+
SerializedConfig,
8+
TestAnnotation,
9+
} from 'vitest'
310
import type { BrowserRunnerState } from '../../../types'
411
import { createFileTask } from '@vitest/runner/utils'
512
import { createClient, getTasks } from '@vitest/ws-client'
@@ -29,7 +36,7 @@ export const client = (function createVitestClient() {
2936
onTestAnnotate(testId: string, annotation: TestAnnotation) {
3037
explorerTree.annotateTest(testId, annotation)
3138
},
32-
onTaskUpdate(packs: TaskResultPack[], events: RunnerTaskEventPack[]) {
39+
onTaskUpdate(packs: RunnerTaskResultPack[], events: RunnerTaskEventPack[]) {
3340
explorerTree.resumeRun(packs, events)
3441
testRunState.value = 'running'
3542
},
@@ -65,7 +72,7 @@ export const currentLogs = computed(() => getTasks(current.value).map(i => i?.lo
6572

6673
export function findById(id: string) {
6774
const file = client.state.idMap.get(id)
68-
return file ? file as File : undefined
75+
return file ? file as RunnerTestFile : undefined
6976
}
7077

7178
export const isConnected = computed(() => status.value === 'OPEN')
@@ -76,7 +83,7 @@ export function runAll() {
7683
return runFiles(client.state.getFiles())
7784
}
7885

79-
function clearTaskResult(task: Task) {
86+
function clearTaskResult(task: RunnerTask) {
8087
delete task.result
8188
const node = explorerTree.nodes.get(task.id)
8289
if (node) {
@@ -90,7 +97,7 @@ function clearTaskResult(task: Task) {
9097
}
9198
}
9299

93-
function clearResults(useFiles: File[]) {
100+
function clearResults(useFiles: RunnerTestFile[]) {
94101
const map = explorerTree.nodes
95102
useFiles.forEach((f) => {
96103
delete f.result
@@ -115,15 +122,15 @@ function clearResults(useFiles: File[]) {
115122
})
116123
}
117124

118-
export function runFiles(useFiles: File[]) {
125+
export function runFiles(useFiles: RunnerTestFile[]) {
119126
clearResults(useFiles)
120127

121128
explorerTree.startRun()
122129

123130
return client.rpc.rerun(useFiles.map(i => i.filepath), true)
124131
}
125132

126-
export function runTask(task: Task) {
133+
export function runTask(task: RunnerTask) {
127134
clearTaskResult(task)
128135

129136
explorerTree.startRun()

packages/ui/client/composables/client/static.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { VitestClient } from '@vitest/ws-client'
22
import type { BirpcReturn } from 'birpc'
33
import type {
4-
File,
54
ModuleGraphData,
5+
RunnerTestFile,
66
SerializedConfig,
77
WebSocketEvents,
88
WebSocketHandlers,
@@ -13,7 +13,7 @@ import { StateManager } from '../../../../ws-client/src/state'
1313

1414
interface HTMLReportMetadata {
1515
paths: string[]
16-
files: File[]
16+
files: RunnerTestFile[]
1717
config: SerializedConfig
1818
projects: string[]
1919
moduleGraph: Record<string, Record<string, ModuleGraphData>>

packages/ui/client/utils/task.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import type { Suite, Task } from 'vitest'
1+
import type { RunnerTask, RunnerTestSuite } from 'vitest'
22

3-
export function isSuite(task: Task): task is Suite {
3+
export function isSuite(task: RunnerTask): task is RunnerTestSuite {
44
return Object.hasOwnProperty.call(task, 'tasks')
55
}
66

7-
export function isTaskDone(task: Task) {
7+
export function isTaskDone(task: RunnerTask) {
88
const state = task.result?.state
99
const mode = task.mode
1010

packages/vitest/src/public/index.ts

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
import type {
2-
Custom as Custom_,
3-
DoneCallback as DoneCallback_,
4-
File as File_,
5-
Suite as Suite_,
6-
Task as Task_,
7-
TaskBase as TaskBase_,
8-
TaskResult as TaskResult_,
9-
TaskResultPack as TaskResultPack_,
10-
Test as Test_,
11-
} from '@vitest/runner'
121
import type {
132
/** @deprecated import from `vitest/node` instead */
143
Vitest as Vitest_,
@@ -53,14 +42,6 @@ import type {
5342

5443
import type { SerializedTestSpecification } from '../runtime/types/utils'
5544

56-
import type {
57-
CollectLineNumbers as CollectLineNumbers_,
58-
CollectLines as CollectLines_,
59-
Context as Context_,
60-
RawErrsMap as RawErrsMap_,
61-
RootAndTarget as RootAndTarget_,
62-
TscErrorInfo as TscErrorInfo_,
63-
} from '../typecheck/types'
6445
import type {
6546
WorkerRPC as WorkerRPC_,
6647
} from '../types/worker'
@@ -100,39 +81,6 @@ export type {
10081
} from '../runtime/types/benchmark'
10182
export { assertType } from '../typecheck/assertType'
10283

103-
/** @deprecated import `TypeCheckRawErrorsMap` from `vitest/node` instead */
104-
export type RawErrsMap = RawErrsMap_
105-
/** @deprecated import `TypeCheckErrorInfo` from `vitest/node` instead */
106-
export type TscErrorInfo = TscErrorInfo_
107-
/** @deprecated import `TypeCheckCollectLineNumbers` from `vitest/node` instead */
108-
export type CollectLineNumbers = CollectLineNumbers_
109-
/** @deprecated import `TypeCheckCollectLines` from `vitest/node` instead */
110-
export type CollectLines = CollectLines_
111-
/** @deprecated import `TypeCheckRootAndTarget` from `vitest/node` instead */
112-
export type RootAndTarget = RootAndTarget_
113-
/** @deprecated import `TypeCheckContext` from `vitest/node` instead */
114-
export type Context = Context_
115-
116-
/** @deprecated use `RunnerTestSuite` instead */
117-
export type Suite = Suite_
118-
/** @deprecated use `RunnerTestFile` instead */
119-
export type File = File_
120-
/** @deprecated use `RunnerTestCase` instead */
121-
export type Test = Test_
122-
/** @deprecated do not use `Custom`, use `RunnerTestCase` instead */
123-
export type Custom = Custom_
124-
/** @deprecated use `RunnerTask` instead */
125-
export type Task = Task_
126-
/** @deprecated use `RunnerTaskBase` instead */
127-
export type TaskBase = TaskBase_
128-
/** @deprecated use `RunnerTaskResult` instead */
129-
export type TaskResult = TaskResult_
130-
/** @deprecated use `RunnerTaskResultPack` instead */
131-
export type TaskResultPack = TaskResultPack_
132-
133-
/** @deprecated don't use `DoneCallback` since it's not supported */
134-
export type DoneCallback = DoneCallback_
135-
13684
export type { AssertType } from '../typecheck/assertType'
13785
export { expectTypeOf } from '../typecheck/expectTypeOf'
13886
export type { ExpectTypeOf } from '../typecheck/expectTypeOf'

test/reporters/src/context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { Vitest } from '../../../packages/vitest/src/node/core'
33
import type { Logger } from '../../../packages/vitest/src/node/logger'
44
import type { StateManager } from '../../../packages/vitest/src/node/state'
55
import type { ResolvedConfig } from '../../../packages/vitest/src/node/types/config'
6-
import type { File } from '../../../packages/vitest/src/public/index'
6+
import type { RunnerTestFile } from '../../../packages/vitest/src/public/index'
77

88
interface Context {
99
vitest: Vitest
@@ -26,7 +26,7 @@ export function getContext(): Context {
2626
}
2727

2828
const state: Partial<StateManager> = {
29-
filesMap: new Map<string, File[]>(),
29+
filesMap: new Map<string, RunnerTestFile[]>(),
3030
}
3131

3232
const context: Partial<Vitest> = {

test/reporters/src/data.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Suite, Task, TestError } from 'vitest'
1+
import type { RunnerTestCase, RunnerTestSuite, TestError } from 'vitest'
22
import { createFileTask } from '@vitest/runner/utils'
33

44
const file = createFileTask(
@@ -12,7 +12,7 @@ file.result = {
1212
duration: 145.99284195899963,
1313
}
1414

15-
const suite: Suite = {
15+
const suite: RunnerTestSuite = {
1616
id: `${file.id}_0`,
1717
type: 'suite',
1818
name: 'suite',
@@ -68,7 +68,7 @@ error.stack = 'AssertionError: expected 2.23606797749979 to equal 2\n'
6868
+ ' at async run (/vitest/packages/vitest/dist/entry.js:1797:5)\n'
6969
+ ' at async file:///vitest/node_modules/.pnpm/tinypool@0.1.1/node_modules/tinypool/dist/esm/worker.js:96:20'
7070

71-
const tasks: Task[] = [
71+
const tasks: RunnerTestCase[] = [
7272
{
7373
id: `${suite.id}_0`,
7474
type: 'test',

test/reporters/tests/junit.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { File, Suite, Task, TaskResult } from 'vitest'
1+
import type { RunnerTaskResult, RunnerTestCase, RunnerTestFile, RunnerTestSuite } from 'vitest'
22
import { createFileTask } from '@vitest/runner/utils'
33
import { resolve } from 'pathe'
44
import { expect, test } from 'vitest'
@@ -8,9 +8,9 @@ import { runVitest, runVitestCli } from '../../test-utils'
88
const root = resolve(__dirname, '../fixtures')
99

1010
test('calc the duration used by junit', () => {
11-
const result: TaskResult = { state: 'pass', duration: 0 }
12-
const file: File = createFileTask('/test.ts', '/', 'test')
13-
const suite: Suite = {
11+
const result: RunnerTaskResult = { state: 'pass', duration: 0 }
12+
const file: RunnerTestFile = createFileTask('/test.ts', '/', 'test')
13+
const suite: RunnerTestSuite = {
1414
id: '1_0',
1515
type: 'suite',
1616
name: 'suite',
@@ -19,7 +19,7 @@ test('calc the duration used by junit', () => {
1919
file,
2020
meta: {},
2121
}
22-
const task: Task = {
22+
const task: RunnerTestCase = {
2323
id: '1_0_0',
2424
type: 'test',
2525
name: 'timeout',

0 commit comments

Comments
 (0)