Skip to content

Commit

Permalink
chore: run typecheck in unit tests (#18858)
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa authored Dec 2, 2024
1 parent b39e696 commit 49f20bb
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"build": "premove dist && pnpm build-bundle && pnpm build-types",
"build-bundle": "rollup --config rollup.config.ts --configPlugin esbuild",
"build-types": "pnpm build-types-temp && pnpm build-types-roll && pnpm build-types-check",
"build-types-temp": "tsc --emitDeclarationOnly --outDir temp -p src/node",
"build-types-temp": "tsc --emitDeclarationOnly --outDir temp -p src/node/tsconfig.build.json",
"build-types-roll": "rollup --config rollup.dts.config.ts --configPlugin esbuild && premove temp",
"build-types-check": "tsc --project tsconfig.check.json",
"typecheck": "tsc --noEmit && tsc --noEmit -p src/node",
Expand Down
4 changes: 2 additions & 2 deletions packages/vite/src/node/__tests__/config.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import http from 'node:http'
import { describe, expect, test } from 'vitest'
import type { InlineConfig } from '..'
import type { PluginOption, UserConfig, UserConfigExport } from '../config'
import type { InlineConfig, PluginOption } from '..'
import type { UserConfig, UserConfigExport } from '../config'
import { defineConfig, resolveConfig } from '../config'
import { resolveEnvPrefix } from '../env'
import { createLogger, mergeConfig } from '../publicUtils'
Expand Down
6 changes: 5 additions & 1 deletion packages/vite/src/node/__tests__/plugins/json.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ test('can extract json error position', () => {
})

describe('transform', () => {
const transform = (input: string, opts: JsonOptions, isBuild: boolean) => {
const transform = (
input: string,
opts: Required<JsonOptions>,
isBuild: boolean,
) => {
const plugin = jsonPlugin(opts, isBuild)
return (plugin.transform! as Function)(input, 'test.json').code
}
Expand Down
8 changes: 0 additions & 8 deletions packages/vite/src/node/__tests__/tsconfig.json

This file was deleted.

1 change: 1 addition & 0 deletions packages/vite/src/node/ssr/runtime/__tests__/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export async function createModuleRunnerTester(
}

beforeEach<TestClient>(async (t) => {
// @ts-ignore
globalThis.__HMR__ = {}

t.server = await createServer({
Expand Down
4 changes: 4 additions & 0 deletions packages/vite/src/node/tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["**/__tests__"]
}
2 changes: 1 addition & 1 deletion packages/vite/src/node/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "../../tsconfig.base.json",
"include": ["./", "../module-runner", "../types"],
"exclude": ["../**/__tests__"],
"exclude": ["**/fixtures"],
"compilerOptions": {
// https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping#node-18
"lib": ["ES2023", "DOM"], // DOM because we have client code that gets inlined via function.toString()
Expand Down

0 comments on commit 49f20bb

Please sign in to comment.