From 00dc983098fd5175da62a09ff7d79b7930c383ad Mon Sep 17 00:00:00 2001 From: Lachlan Collins <1667261+lachlancollins@users.noreply.github.com> Date: Wed, 3 Jan 2024 22:29:55 +1100 Subject: [PATCH] ci: Run `test:types` on CI (#9) * chore: Add type checking * Use moduleResolution bundler * Re-enable strict mode --- bin/config.js | 2 ++ package.json | 6 ++++-- tsconfig.json | 24 ++++++++++++++---------- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/bin/config.js b/bin/config.js index b048945..d5755c6 100755 --- a/bin/config.js +++ b/bin/config.js @@ -26,9 +26,11 @@ async function requireOrImport(path) { try { return require(path) } catch (e) { + // @ts-expect-error if (pathToFileURL && e.code === 'ERR_REQUIRE_ESM') { // This is needed on Windows, because import() fails if providing a Windows file path. const url = pathToFileURL(path) + // @ts-expect-error return import(url) } throw e diff --git a/package.json b/package.json index 8239881..f0475fa 100644 --- a/package.json +++ b/package.json @@ -48,15 +48,17 @@ "prettier": "prettier --ignore-unknown '**/*'", "prettier:write": "pnpm run prettier --write", "test:build": "publint --strict", + "test:types": "tsc", "test:eslint": "eslint --ext .ts,.tsx src", "test:format": "pnpm run prettier --check", - "test:pr": "nx run-many --targets=test:format,test:eslint,test:build", - "test:ci": "nx run-many --targets=test:format,test:eslint,test:build" + "test:pr": "nx run-many --targets=test:format,test:eslint,test:types,test:build", + "test:ci": "nx run-many --targets=test:format,test:eslint,test:types,test:build" }, "nx": { "includedScripts": [ "test:format", "test:eslint", + "test:types", "test:build" ] }, diff --git a/tsconfig.json b/tsconfig.json index bad82b3..9dda06b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,20 +1,24 @@ { "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { - "lib": ["ES2022"], - "target": "ES2020", - "module": "ES2020", - "moduleResolution": "node", + "allowJs": true, "allowSyntheticDefaultImports": true, - "strict": true, - "noUncheckedIndexedAccess": true, - "strictNullChecks": true, + "allowUnreachableCode": true, + "baseUrl": ".", + "checkJs": true, "declaration": true, - "noImplicitReturns": true, "esModuleInterop": true, + "lib": ["ES2022"], + "module": "ES2020", + "moduleResolution": "Bundler", + "noEmit": true, + "noImplicitAny": false, + "noImplicitReturns": true, + "noUncheckedIndexedAccess": true, "skipLibCheck": true, - "baseUrl": ".", - "allowUnreachableCode": true + "strict": true, + "strictNullChecks": true, + "target": "ES2020" }, "include": ["bin", "prettier.config.js", "src"] }