Add type-check and unify tsconfig (#10667)

This adds a new `pnpm type-check` that leverages `turbo` to validate the TypeScript code. This can be run at the top-level or for an individual package.

The `test-lint` workflow will run it after linting and doing the prettier check.

As apart of this effort, each package's `tsconfig.json` has been simplified. There's a new top-level `tsconfig.base.json` file that extends the Vercel Style Guide for TypeScript. Each package's `tsconfig.json` has been audited and previously suppressed rules that no longer apply have been removed. The result is each package's `tsconfig.json` is greatly simplified and we can control common settings in the base config while keeping the flexibility of package-level overrides.

Lastly, in `package/cli`, `pnpm build` calls `scripts/build.mjs` which calls `scripts/compile-templates.mjs`. The `compile-templates.mjs` file was generating invalid TypeScript code. I've fixed it and now it's happier than ever.

Note: In order to run `pnpm type-check`, you must first `pnpm build` because we need the `.d.ts` definition files.
This commit is contained in:
Chris Barber
2023-10-09 06:58:23 -05:00
committed by GitHub
parent d8179032e2
commit 222710f612
48 changed files with 452 additions and 340 deletions

View File

@@ -17,7 +17,8 @@
"build": "node ../../utils/build-builder.mjs",
"test": "jest --reporters=default --reporters=jest-junit --env node --verbose --runInBand --bail",
"test-unit": "pnpm test test/unit.test.ts",
"test-e2e": "pnpm test test/integration-*"
"test-e2e": "pnpm test test/integration-*",
"type-check": "tsc --noEmit"
},
"devDependencies": {
"@types/execa": "^0.9.0",

View File

@@ -1,19 +1,8 @@
{
"compilerOptions": {
"declaration": false,
"esModuleInterop": true,
"lib": ["ES2021"],
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "dist",
"types": ["node", "jest"],
"strict": true,
"target": "ES2021"
"outDir": "./dist",
"types": ["node", "jest"]
},
"extends": "../../tsconfig.base.json",
"include": ["src/**/*"]
}