Skip to content

Commit

Permalink
chore: also typecheck src/node/__test__
Browse files Browse the repository at this point in the history
  • Loading branch information
ArnaudBarre committed Dec 10, 2022
1 parent 3dc4545 commit f2f4e6f
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -17,7 +17,7 @@
"postinstall": "simple-git-hooks",
"format": "prettier --write --cache .",
"lint": "eslint --cache .",
"typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit && tsc -p packages/create-vite --noEmit && tsc -p packages/vite/scripts --noEmit",
"typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit && tsc -p packages/create-vite --noEmit && tsc -p packages/vite --noEmit",
"test": "run-s test-unit test-serve test-build",
"test-serve": "vitest run -c vitest.config.e2e.ts",
"test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",
Expand Down
6 changes: 0 additions & 6 deletions packages/vite/scripts/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion packages/vite/src/node/__tests__/build.spec.ts
Expand Up @@ -421,7 +421,7 @@ describe('resolveBuildOutputs', () => {
})

test('array outputs: should ignore build.lib.formats', () => {
const log = { warn: vi.fn() } as Logger
const log = { warn: vi.fn() } as unknown as Logger
expect(
resolveBuildOutputs(
[{ name: 'A' }],
Expand Down
4 changes: 3 additions & 1 deletion packages/vite/src/node/__tests__/plugins/define.spec.ts
Expand Up @@ -10,7 +10,9 @@ async function createDefinePluginTransform(
const config = await resolveConfig({ define }, build ? 'build' : 'serve')
const instance = definePlugin(config)
return async (code: string) => {
const result = await instance.transform.call({}, code, 'foo.ts', { ssr })
const result = await (instance.transform as any).call({}, code, 'foo.ts', {
ssr,
})
return result?.code || result
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/vite/src/node/__tests__/plugins/esbuild.spec.ts
@@ -1,7 +1,6 @@
import { describe, expect, test } from 'vitest'
import type { ResolvedConfig, UserConfig } from '../../config'
import {
ESBuildTransformResult,
resolveEsbuildTranspileOptions,
transformWithEsbuild,
} from '../../plugins/esbuild'
Expand Down
14 changes: 9 additions & 5 deletions packages/vite/src/node/__tests__/scan.spec.ts
Expand Up @@ -15,14 +15,14 @@ describe('optimizer-scan:script-test', () => {
scriptRE.lastIndex = 0
const [, tsOpenTag, tsContent] = scriptRE.exec(
`<script lang="ts">${scriptContent}</script>`,
)
)!
expect(tsOpenTag).toEqual('<script lang="ts">')
expect(tsContent).toEqual(scriptContent)

scriptRE.lastIndex = 0
const [, openTag, content] = scriptRE.exec(
`<script>${scriptContent}</script>`,
)
)!
expect(openTag).toEqual('<script>')
expect(content).toEqual(scriptContent)
})
Expand Down Expand Up @@ -58,12 +58,16 @@ describe('optimizer-scan:script-test', () => {

test('ordinary script tag test', () => {
scriptRE.lastIndex = 0
const [, tag, content] = scriptRE.exec(`<script >var test = null</script>`)
const [, tag, content] = scriptRE.exec(
`<script >var test = null</script>`,
)!
expect(tag).toEqual('<script >')
expect(content).toEqual('var test = null')

scriptRE.lastIndex = 0
const [, tag1, content1] = scriptRE.exec(`<script>var test = null</script>`)
const [, tag1, content1] = scriptRE.exec(
`<script>var test = null</script>`,
)!
expect(tag1).toEqual('<script>')
expect(content1).toEqual('var test = null')
})
Expand All @@ -90,7 +94,7 @@ describe('optimizer-scan:script-test', () => {

shouldMatchArray.forEach((str) => {
importsRE.lastIndex = 0
expect(importsRE.exec(str)[1]).toEqual("'vue'")
expect(importsRE.exec(str)![1]).toEqual("'vue'")
})

const shouldFailArray = [
Expand Down
10 changes: 8 additions & 2 deletions packages/vite/tsconfig.json
@@ -1,8 +1,14 @@
{
"extends": "./tsconfig.base.json",
"include": [
"./rollup.config.ts",
"scripts",
"src/node/__tests__",
"src/types/shims.d.ts"
],
"compilerOptions": {
"esModuleInterop": true,
"declaration": false,
"resolveJsonModule": true
},
"include": ["./rollup.config.ts"]
}
}

0 comments on commit f2f4e6f

Please sign in to comment.