Skip to content

Commit f2f4e6f

Browse files
committed
chore: also typecheck src/node/__test__
1 parent 3dc4545 commit f2f4e6f

File tree

7 files changed

+22
-17
lines changed

7 files changed

+22
-17
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"postinstall": "simple-git-hooks",
1818
"format": "prettier --write --cache .",
1919
"lint": "eslint --cache .",
20-
"typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit && tsc -p packages/create-vite --noEmit && tsc -p packages/vite/scripts --noEmit",
20+
"typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit && tsc -p packages/create-vite --noEmit && tsc -p packages/vite --noEmit",
2121
"test": "run-s test-unit test-serve test-build",
2222
"test-serve": "vitest run -c vitest.config.e2e.ts",
2323
"test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",

packages/vite/scripts/tsconfig.json

-6
This file was deleted.

packages/vite/src/node/__tests__/build.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ describe('resolveBuildOutputs', () => {
421421
})
422422

423423
test('array outputs: should ignore build.lib.formats', () => {
424-
const log = { warn: vi.fn() } as Logger
424+
const log = { warn: vi.fn() } as unknown as Logger
425425
expect(
426426
resolveBuildOutputs(
427427
[{ name: 'A' }],

packages/vite/src/node/__tests__/plugins/define.spec.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ async function createDefinePluginTransform(
1010
const config = await resolveConfig({ define }, build ? 'build' : 'serve')
1111
const instance = definePlugin(config)
1212
return async (code: string) => {
13-
const result = await instance.transform.call({}, code, 'foo.ts', { ssr })
13+
const result = await (instance.transform as any).call({}, code, 'foo.ts', {
14+
ssr,
15+
})
1416
return result?.code || result
1517
}
1618
}

packages/vite/src/node/__tests__/plugins/esbuild.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { describe, expect, test } from 'vitest'
22
import type { ResolvedConfig, UserConfig } from '../../config'
33
import {
4-
ESBuildTransformResult,
54
resolveEsbuildTranspileOptions,
65
transformWithEsbuild,
76
} from '../../plugins/esbuild'

packages/vite/src/node/__tests__/scan.spec.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ describe('optimizer-scan:script-test', () => {
1515
scriptRE.lastIndex = 0
1616
const [, tsOpenTag, tsContent] = scriptRE.exec(
1717
`<script lang="ts">${scriptContent}</script>`,
18-
)
18+
)!
1919
expect(tsOpenTag).toEqual('<script lang="ts">')
2020
expect(tsContent).toEqual(scriptContent)
2121

2222
scriptRE.lastIndex = 0
2323
const [, openTag, content] = scriptRE.exec(
2424
`<script>${scriptContent}</script>`,
25-
)
25+
)!
2626
expect(openTag).toEqual('<script>')
2727
expect(content).toEqual(scriptContent)
2828
})
@@ -58,12 +58,16 @@ describe('optimizer-scan:script-test', () => {
5858

5959
test('ordinary script tag test', () => {
6060
scriptRE.lastIndex = 0
61-
const [, tag, content] = scriptRE.exec(`<script >var test = null</script>`)
61+
const [, tag, content] = scriptRE.exec(
62+
`<script >var test = null</script>`,
63+
)!
6264
expect(tag).toEqual('<script >')
6365
expect(content).toEqual('var test = null')
6466

6567
scriptRE.lastIndex = 0
66-
const [, tag1, content1] = scriptRE.exec(`<script>var test = null</script>`)
68+
const [, tag1, content1] = scriptRE.exec(
69+
`<script>var test = null</script>`,
70+
)!
6771
expect(tag1).toEqual('<script>')
6872
expect(content1).toEqual('var test = null')
6973
})
@@ -90,7 +94,7 @@ describe('optimizer-scan:script-test', () => {
9094

9195
shouldMatchArray.forEach((str) => {
9296
importsRE.lastIndex = 0
93-
expect(importsRE.exec(str)[1]).toEqual("'vue'")
97+
expect(importsRE.exec(str)![1]).toEqual("'vue'")
9498
})
9599

96100
const shouldFailArray = [

packages/vite/tsconfig.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
{
22
"extends": "./tsconfig.base.json",
3+
"include": [
4+
"./rollup.config.ts",
5+
"scripts",
6+
"src/node/__tests__",
7+
"src/types/shims.d.ts"
8+
],
39
"compilerOptions": {
10+
"esModuleInterop": true,
411
"declaration": false,
512
"resolveJsonModule": true
6-
},
7-
"include": ["./rollup.config.ts"]
13+
}
814
}

0 commit comments

Comments
 (0)