Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/runner/src/types/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ export interface TestAttachment {
/** File system path to the attachment */
path?: string
/** Inline attachment content as a string or raw binary data */
body?: string | Uint8Array
body?: string | Uint8Array | undefined
}

export interface Location {
Expand Down
6 changes: 6 additions & 0 deletions packages/spy/optional-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable ts/ban-ts-comment */

export interface Disposable {
// @ts-ignore -- Symbol.dispose might not be in user types
[Symbol.dispose]: () => void
}
6 changes: 5 additions & 1 deletion packages/spy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./optional-types.js": {
"types": "./optional-types.d.ts"
},
"./*": "./*"
},
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"files": [
"dist"
"dist",
"optional-types.d.ts"
],
"scripts": {
"build": "premove dist && rollup -c",
Expand Down
1 change: 1 addition & 0 deletions packages/spy/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const external = [
...builtinModules,
...Object.keys(pkg.dependencies || {}),
...Object.keys(pkg.peerDependencies || {}),
'@vitest/spy/optional-types.js',
]

const dtsUtils = createDtsUtils()
Expand Down
2 changes: 2 additions & 0 deletions packages/spy/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { Disposable } from '@vitest/spy/optional-types.js'

export interface MockResultReturn<T> {
type: 'return'
/**
Expand Down
6 changes: 6 additions & 0 deletions packages/vitest/optional-runtime-types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* eslint-disable ts/ban-ts-comment */

export interface Disposable {
// @ts-ignore -- Symbol.dispose might not be in user types
[Symbol.dispose]: () => void
}
3 changes: 3 additions & 0 deletions packages/vitest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
"./optional-types.js": {
"types": "./optional-types.d.ts"
},
"./optional-runtime-types.js": {
"types": "./optional-runtime-types.d.ts"
},
"./src/*": "./src/*",
"./globals": {
"types": "./globals.d.ts"
Expand Down
1 change: 1 addition & 0 deletions packages/vitest/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const external = [
'node:console',
'node:events',
'inspector',
'vitest/optional-runtime-types.js',
'vitest/optional-types.js',
'vitest/browser',
'vite/module-runner',
Expand Down
1 change: 1 addition & 0 deletions packages/vitest/src/integrations/vi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {
MaybePartiallyMockedDeep,
MockInstance,
} from '@vitest/spy'
import type { Disposable } from 'vitest/optional-runtime-types.js'
import type { RuntimeOptions, SerializedConfig } from '../runtime/config'
import type { VitestMocker } from '../runtime/moduleRunner/moduleMocker'
import type { MockFactoryWithHelper, MockOptions } from '../types/mocker'
Expand Down
20 changes: 19 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import type { VitestRunner } from '@vitest/runner'
import type { FailureScreenshotArtifact } from '@vitest/runner/types'
import { VitestTestRunner } from 'vitest/runners'

type _Override = FailureScreenshotArtifact

export class MyRunner extends VitestTestRunner implements VitestRunner {}
17 changes: 17 additions & 0 deletions test/cli/dts/exact-optional-property-no-node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": ["../_shared/tsconfig.patch.json"],
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": [],
"strict": true,
"exactOptionalPropertyTypes": true,
"declaration": true,
"declarationMap": true,
"outDir": "dist",
"sourceMap": true,
"verbatimModuleSyntax": true,
"skipLibCheck": false
}
}
12 changes: 12 additions & 0 deletions test/cli/dts/exact-optional-property-node/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@vitest/test-integration-dts-exact-optional-property",
"type": "module",
"private": true,
"scripts": {
"test": "tsc -b"
},
"devDependencies": {
"@vitest/runner": "workspace:*",
"vitest": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { File } from '@vitest/runner'
import { DefaultReporter } from 'vitest/reporters'
import { DefaultReporter } from 'vitest/node'

export class MyReporter extends DefaultReporter {
override reportTestSummary(files: File[], errors: unknown[], leakCount: number): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "Bundler",
"types": [],
"strict": true,
"exactOptionalPropertyTypes": true,
"declaration": true,
Expand Down
12 changes: 12 additions & 0 deletions test/cli/dts/no-dispose/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@vitest/test-integration-dts-exact-optional-property",
"type": "module",
"private": true,
"scripts": {
"test": "tsc -b"
},
"devDependencies": {
"@vitest/runner": "workspace:*",
"vitest": "workspace:*"
}
}
4 changes: 4 additions & 0 deletions test/cli/dts/no-dispose/src/vitest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { vi } from 'vitest'

const _fn = vi.fn()
const _mock = vi.doMock('./vitest.ts')
17 changes: 17 additions & 0 deletions test/cli/dts/no-dispose/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": ["../_shared/tsconfig.patch.json"],
"compilerOptions": {
"target": "es2020",
"lib": ["DOM", "ES2020"],
"module": "node16",
"types": [],
"strict": true,
"declaration": true,
"declarationMap": true,
"outDir": "dist",
"sourceMap": true,
"verbatimModuleSyntax": true,
"skipLibCheck": false
},
"include": ["src/*.ts"]
}
Loading