From d833896795fe03b4090ef073a9bbc08c7ee1bab0 Mon Sep 17 00:00:00 2001 From: Kevin Barabash Date: Wed, 15 Feb 2023 11:19:22 -0500 Subject: [PATCH] re-arrange base tsconfigs, ensure that type checking results are the same between 'typecheck' and 'build:types' --- .github/workflows/node-ci.yml | 2 +- package.json | 3 +- packages/tsconfig-shared.json | 16 ++------- packages/wonder-stuff-core/tsconfig.json | 2 +- packages/wonder-stuff-i18n/tsconfig.json | 2 +- packages/wonder-stuff-sentry/tsconfig.json | 2 +- .../wonder-stuff-server-google/tsconfig.json | 2 +- packages/wonder-stuff-server/tsconfig.json | 2 +- packages/wonder-stuff-testing/tsconfig.json | 3 +- tsconfig-build.json | 3 +- tsconfig-check.json | 13 ++++++++ tsconfig-common.json | 30 +++++++++++++++++ tsconfig.json | 33 ------------------- 13 files changed, 58 insertions(+), 55 deletions(-) create mode 100644 tsconfig-check.json create mode 100644 tsconfig-common.json delete mode 100644 tsconfig.json diff --git a/.github/workflows/node-ci.yml b/.github/workflows/node-ci.yml index 91a84ac5..f8138cb1 100644 --- a/.github/workflows/node-ci.yml +++ b/.github/workflows/node-ci.yml @@ -73,7 +73,7 @@ jobs: run: yarn build - name: Build Types - run: yarn build:types + run: yarn build:types && rm -rf packages/*/dist/**/__types__ # Linting / type checking - name: Eslint diff --git a/package.json b/package.json index ab6f471d..f21d0232 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "build:prodsizecheck": "rollup -c build-settings/rollup.config.js --configPlatforms='browser' --configFormats='esm' --configEnvironment='production'", "build:types": "yarn tsc --build --verbose tsconfig-build.json", "watch": "rollup -c build-settings/rollup.config.js --watch", + "watch:types": "yarn build:types --watch", "clean": "rm -rf packages/wonder-stuff-*/dist && rm -rf packages/wonder-stuff-*/node_modules && rm -f packages/*/tsconfig.tsbuildinfo", "coverage": "yarn run jest --coverage", "format": "prettier --write .", @@ -82,7 +83,7 @@ "lint:ci": "eslint --config .eslintrc.js", "publish:ci": "node utils/pre-publish-check-ci.js && git diff --stat --exit-code HEAD && yarn build && changeset publish", "test": "yarn jest", - "typecheck": "tsc --noEmit", + "typecheck": "tsc --project tsconfig-check.json", "nochangeset": "yarn changeset add --empty" } } \ No newline at end of file diff --git a/packages/tsconfig-shared.json b/packages/tsconfig-shared.json index 03c8f7e2..5daceea7 100644 --- a/packages/tsconfig-shared.json +++ b/packages/tsconfig-shared.json @@ -1,6 +1,7 @@ +// This file is used by the tsconfig.json files in each package. /* Visit https://aka.ms/tsconfig to read more about this file */ { - "exclude": ["dist"], + "extends": "../tsconfig-common.json", "compilerOptions": { "composite": true, "incremental": true, // Required for composite projects @@ -10,20 +11,9 @@ "declaration": true, "emitDeclarationOnly": true, - "target": "ES2016", - // Required for dynamic imports even though we aren't using - // tsc to output any modules. - "module": "esnext", - "esModuleInterop": true, - "resolveJsonModule": true, - "moduleResolution": "node", - - "strict": true, - "noImplicitAny": true, - "paths": { "@khanacademy/*": [ - "./packages/*/src" + "./*/src" ] }, }, diff --git a/packages/wonder-stuff-core/tsconfig.json b/packages/wonder-stuff-core/tsconfig.json index 35cad7f7..8bebeb02 100644 --- a/packages/wonder-stuff-core/tsconfig.json +++ b/packages/wonder-stuff-core/tsconfig.json @@ -1,5 +1,5 @@ { - "exclude": ["dist"], + "exclude": ["dist", "**/*.flowtest.ts"], "extends": "../tsconfig-shared.json", "compilerOptions": { "outDir": "dist", diff --git a/packages/wonder-stuff-i18n/tsconfig.json b/packages/wonder-stuff-i18n/tsconfig.json index 35cad7f7..8bebeb02 100644 --- a/packages/wonder-stuff-i18n/tsconfig.json +++ b/packages/wonder-stuff-i18n/tsconfig.json @@ -1,5 +1,5 @@ { - "exclude": ["dist"], + "exclude": ["dist", "**/*.flowtest.ts"], "extends": "../tsconfig-shared.json", "compilerOptions": { "outDir": "dist", diff --git a/packages/wonder-stuff-sentry/tsconfig.json b/packages/wonder-stuff-sentry/tsconfig.json index d822c9f3..d74ddfac 100644 --- a/packages/wonder-stuff-sentry/tsconfig.json +++ b/packages/wonder-stuff-sentry/tsconfig.json @@ -1,5 +1,5 @@ { - "exclude": ["dist"], + "exclude": ["dist", "**/*.flowtest.ts"], "extends": "../tsconfig-shared.json", "compilerOptions": { "outDir": "dist", diff --git a/packages/wonder-stuff-server-google/tsconfig.json b/packages/wonder-stuff-server-google/tsconfig.json index 84e892ec..48645b9f 100644 --- a/packages/wonder-stuff-server-google/tsconfig.json +++ b/packages/wonder-stuff-server-google/tsconfig.json @@ -1,5 +1,5 @@ { - "exclude": ["dist"], + "exclude": ["dist", "**/*.flowtest.ts"], "extends": "../tsconfig-shared.json", "compilerOptions": { "outDir": "dist", diff --git a/packages/wonder-stuff-server/tsconfig.json b/packages/wonder-stuff-server/tsconfig.json index aec43e53..cf71e9b2 100644 --- a/packages/wonder-stuff-server/tsconfig.json +++ b/packages/wonder-stuff-server/tsconfig.json @@ -1,5 +1,5 @@ { - "exclude": ["dist"], + "exclude": ["dist", "**/*.flowtest.ts"], "extends": "../tsconfig-shared.json", "compilerOptions": { "outDir": "./dist", diff --git a/packages/wonder-stuff-testing/tsconfig.json b/packages/wonder-stuff-testing/tsconfig.json index 2bd14567..d74ddfac 100644 --- a/packages/wonder-stuff-testing/tsconfig.json +++ b/packages/wonder-stuff-testing/tsconfig.json @@ -1,5 +1,6 @@ { - "exclude": ["dist"], + "exclude": ["dist", "**/*.flowtest.ts"], + "extends": "../tsconfig-shared.json", "compilerOptions": { "outDir": "dist", "rootDir": "src", diff --git a/tsconfig-build.json b/tsconfig-build.json index d567e5ee..cccfd543 100644 --- a/tsconfig-build.json +++ b/tsconfig-build.json @@ -1,3 +1,4 @@ +// This file is used by the `build:types` command in package.json /* Visit https://aka.ms/tsconfig to read more about this file */ { // Intentionally empty, all files are covered by tsconfig.json files @@ -10,5 +11,5 @@ {"path": "./packages/wonder-stuff-server"}, {"path": "./packages/wonder-stuff-server-google"}, {"path": "./packages/wonder-stuff-testing"}, - ] + ], } diff --git a/tsconfig-check.json b/tsconfig-check.json new file mode 100644 index 00000000..ab9e57e3 --- /dev/null +++ b/tsconfig-check.json @@ -0,0 +1,13 @@ +// This file is used by the `typecheck` command in package.json +/* Visit https://aka.ms/tsconfig to read more about this file */ +{ + "exclude": ["**/dist", "**/*.flowtest.ts"], + "extends": "./tsconfig-common.json", + "compilerOptions": { + "noEmit": true, + + "paths": { + "@khanacademy/*": ["./packages/*/src"] + }, + } +} diff --git a/tsconfig-common.json b/tsconfig-common.json new file mode 100644 index 00000000..c09cbfe3 --- /dev/null +++ b/tsconfig-common.json @@ -0,0 +1,30 @@ +// This file contains common compiler options that are used by all tsconfigs +/* Visit https://aka.ms/tsconfig to read more about this file */ +{ + "compilerOptions": { + /* Language and Environment */ + "target": "ES2016", + + /* Modules */ + // Required for dynamic imports even though we aren't using + // tsc to output any modules. + "module": "ESNext", + "moduleResolution": "node", + + /* Interop Constraints */ + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + + /* Type Checking */ + "strict": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "strictPropertyInitialization": true, + "strictBindCallApply": true, + "noImplicitAny": true, + + /* Completeness */ + "skipDefaultLibCheck": true, // it's safe to assume that built-in .d.ts files are correct + "skipLibCheck": false + } +} diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index 654699e2..00000000 --- a/tsconfig.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "exclude": ["**/dist", "**/*.flowtest.ts"], - "compilerOptions": { - /* Visit https://aka.ms/tsconfig to read more about this file */ - - /* Language and Environment */ - "target": "ES2016", - - /* Modules */ - "module": "ESNext", - "moduleResolution": "node", - "paths": { - "@khanacademy/*": ["./packages/*/src/index.ts"], - }, - - /* Emit */ - "noEmit": true, - - /* Interop Constraints */ - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - - /* Type Checking */ - "strict": true, - "noImplicitAny": true, - "allowUnusedLabels": false, - "allowUnreachableCode": false, - - /* Completeness */ - "skipDefaultLibCheck": true, - "skipLibCheck": false - } -}