From cbfbde2882ab1f13e439f191bfa115647908c774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Tue, 6 Sep 2022 22:25:09 +0200 Subject: [PATCH] fix(typescript): Use consistent typescript configs make all packages inherit tsconfig from the root tsconfig --- docker/images/n8n-custom/Dockerfile | 4 +-- packages/cli/jest.config.js | 2 +- packages/cli/tsconfig.json | 27 ++++------------ packages/core/package.json | 5 ++- packages/core/tsconfig.json | 23 ++----------- packages/design-system/.storybook/main.js | 2 +- packages/design-system/src/shims-tsx.d.ts | 13 -------- packages/design-system/tsconfig.json | 39 ++++++++++++----------- packages/editor-ui/jest.config.js | 6 ++-- packages/editor-ui/src/shims-tsx.d.ts | 13 -------- packages/editor-ui/tsconfig.json | 22 ++++--------- packages/node-dev/src/tsconfig-build.json | 13 +------- packages/node-dev/tsconfig.json | 22 +++---------- packages/nodes-base/package.json | 5 ++- packages/nodes-base/tsconfig.json | 20 ++++-------- packages/workflow/package.json | 5 ++- packages/workflow/tsconfig.json | 25 ++------------- tsconfig.json | 28 ++++++++++++++++ 18 files changed, 90 insertions(+), 184 deletions(-) delete mode 100644 packages/design-system/src/shims-tsx.d.ts delete mode 100644 packages/editor-ui/src/shims-tsx.d.ts create mode 100644 tsconfig.json diff --git a/docker/images/n8n-custom/Dockerfile b/docker/images/n8n-custom/Dockerfile index 88642c1a29b5c..f733653266a66 100644 --- a/docker/images/n8n-custom/Dockerfile +++ b/docker/images/n8n-custom/Dockerfile @@ -7,7 +7,7 @@ RUN \ apk --no-cache add git && \ npm install -g run-script-os turbo -COPY turbo.json package.json package-lock.json ./ +COPY turbo.json package.json package-lock.json tsconfig.json ./ COPY packages ./packages RUN chown -R node:node . @@ -21,7 +21,7 @@ RUN \ # TODO: removing dev dependecies is deleting `bn.js`, which breaks the Snowflake node npm prune --omit=dev && \ npm i --omit=dev bn.js && \ - find . -type f -name "*.ts" -o -name "*.js.map" -o -name "*.vue" | xargs rm &&\ + find . -type f -name "*.ts" -o -name "*.js.map" -o -name "*.vue" -o -name "tsconfig.json" | xargs rm &&\ rm -rf node_modules/.cache packages/*/node_modules/.cache packages/*/.turbo .config .npm /tmp/* diff --git a/packages/cli/jest.config.js b/packages/cli/jest.config.js index 267cc93266b17..50f87b329475d 100644 --- a/packages/cli/jest.config.js +++ b/packages/cli/jest.config.js @@ -1,7 +1,7 @@ module.exports = { verbose: true, transform: { - '^.+\\.ts?$': 'ts-jest', + '^.+\\.ts$': 'ts-jest', }, testURL: 'http://localhost/', testRegex: '(/__tests__/.*|(\\.|/)(test))\\.ts$', diff --git a/packages/cli/tsconfig.json b/packages/cli/tsconfig.json index 47213b3d474b7..f1c4f8ce333c5 100644 --- a/packages/cli/tsconfig.json +++ b/packages/cli/tsconfig.json @@ -1,27 +1,17 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "lib": [ - "es2017", - "ES2020.Promise" - ], + "outDir": "dist", "types": [ "node", "jest" ], - "module": "commonjs", - "noImplicitAny": true, - "removeComments": true, - "strictNullChecks": true, - "forceConsistentCasingInFileNames": true, - "noImplicitReturns": true, - "preserveConstEnums": true, - "declaration": true, - "outDir": "./dist/", - "target": "es2017", - "sourceMap": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, - "esModuleInterop": true + // TODO: remove all options below this line + "strict": false, + "noUnusedLocals": false, + "useUnknownInCatchVariables": false, }, "include": [ "**/*.d.ts", @@ -30,10 +20,5 @@ "config/**/*", "src/**/*", "test/**/*" - ], - "exclude": [ - "dist/**/*", - "node_modules/**/*", - "**/*.spec.ts" ] } diff --git a/packages/core/package.json b/packages/core/package.json index 6d8513c19353a..539ac3f6c214b 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -61,17 +61,16 @@ }, "jest": { "transform": { - "^.+\\.tsx?$": "ts-jest" + "^.+\\.ts$": "ts-jest" }, "testURL": "http://localhost/", - "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", + "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)$", "testPathIgnorePatterns": [ "/dist/", "/node_modules/" ], "moduleFileExtensions": [ "ts", - "tsx", "js", "json", "node" diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 70e7a5777b969..2635204e53063 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -1,34 +1,17 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "lib": [ - "es2019" - ], + "outDir": "dist", "types": [ "node", "jest" ], - "module": "commonjs", - "removeComments": true, - "forceConsistentCasingInFileNames": true, - "noImplicitReturns": true, - "strict": true, - "noUnusedLocals": true, - "preserveConstEnums": true, - "declaration": true, - "outDir": "./dist/", - "target": "es2019", - "sourceMap": true, - "esModuleInterop": true, + // TODO: remove all options below this line "useUnknownInCatchVariables": false, }, "include": [ "**/*.d.ts", "src/**/*", "test/**/*" - ], - "exclude": [ - "dist/**/*", - "node_modules/**/*", - "**/*.spec.ts" ] } diff --git a/packages/design-system/.storybook/main.js b/packages/design-system/.storybook/main.js index 471a98cde093f..5ec41a5774eb7 100644 --- a/packages/design-system/.storybook/main.js +++ b/packages/design-system/.storybook/main.js @@ -4,7 +4,7 @@ const path = require('path'); * @type {import('@storybook/core-common').StorybookConfig} */ module.exports = { - stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], + stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|ts)'], addons: [ '@storybook/addon-links', '@storybook/addon-essentials', diff --git a/packages/design-system/src/shims-tsx.d.ts b/packages/design-system/src/shims-tsx.d.ts deleted file mode 100644 index f92b1fd7e31e3..0000000000000 --- a/packages/design-system/src/shims-tsx.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import Vue, { VNode } from 'vue'; - -declare global { - namespace JSX { - // tslint:disable no-empty-interface - interface Element extends VNode {} - // tslint:disable no-empty-interface - interface ElementClass extends Vue {} - interface IntrinsicElements { - [elem: string]: any; - } - } -} diff --git a/packages/design-system/tsconfig.json b/packages/design-system/tsconfig.json index 14b3ee00916c1..aad229d09c06a 100644 --- a/packages/design-system/tsconfig.json +++ b/packages/design-system/tsconfig.json @@ -1,37 +1,40 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { + "outDir": "dist", "target": "esnext", "module": "esnext", - "strict": true, "importHelpers": true, - "moduleResolution": "node", - "declaration": true, - "experimentalDecorators": true, "skipLibCheck": true, - "esModuleInterop": true, "allowJs": true, "allowSyntheticDefaultImports": true, - "sourceMap": true, "baseUrl": ".", - "outDir": "dist", "types": [ - "webpack-env", - "jest", - "vitest/globals" + "webpack-env", + "jest", + "vitest/globals" ], - "typeRoots": [ - "@testing-library", - "@types" + "typeRoots": [ + "@testing-library", + "@types" ], "paths": { - "@/*": ["src/*"] + "@/*": [ + "src/*" + ] }, - "lib": ["esnext", "dom", "dom.iterable", "scripthost"] + "lib": [ + "esnext", + "dom", + "dom.iterable", + "scripthost" + ], + // TODO: remove all options below this line + "noUnusedLocals": false, + "noImplicitReturns": false, }, "include": [ "src/**/*.ts", - "src/**/*.tsx", "src/**/*.vue" - ], - "exclude": ["node_modules"] + ] } diff --git a/packages/editor-ui/jest.config.js b/packages/editor-ui/jest.config.js index 54b1b1d84a203..3a8145055ea00 100644 --- a/packages/editor-ui/jest.config.js +++ b/packages/editor-ui/jest.config.js @@ -1,16 +1,14 @@ module.exports = { moduleFileExtensions: [ 'js', - 'jsx', 'json', 'vue', 'ts', - 'tsx', ], transform: { '^.+\\.vue$': 'vue-jest', '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub', - '^.+\\.tsx?$': 'ts-jest', + '^.+\\.ts$': 'ts-jest', }, moduleNameMapper: { '^@/(.*)$': '/src/$1', @@ -19,7 +17,7 @@ module.exports = { 'jest-serializer-vue', ], testMatch: [ - '**/tests/unit/**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)', + '**/tests/unit/**/*.spec.(js|ts)|**/__tests__/*.(js|ts)', ], testURL: 'http://localhost/', }; diff --git a/packages/editor-ui/src/shims-tsx.d.ts b/packages/editor-ui/src/shims-tsx.d.ts deleted file mode 100644 index 3984b2d45a622..0000000000000 --- a/packages/editor-ui/src/shims-tsx.d.ts +++ /dev/null @@ -1,13 +0,0 @@ -import Vue, { VNode } from 'vue'; - -declare global { - namespace JSX { - // tslint:disable no-empty-interface - interface Element extends VNode {} - // tslint:disable no-empty-interface - interface ElementClass extends Vue {} - interface IntrinsicElements { - [elem: string]: any - } - } -} diff --git a/packages/editor-ui/tsconfig.json b/packages/editor-ui/tsconfig.json index ce5055c3310d3..f0f1ecdde8b77 100644 --- a/packages/editor-ui/tsconfig.json +++ b/packages/editor-ui/tsconfig.json @@ -1,20 +1,12 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { "target": "esnext", "module": "esnext", - "removeComments": true, - "forceConsistentCasingInFileNames": true, - "noImplicitReturns": true, - "strict": true, - "jsx": "preserve", "skipLibCheck": true, + "allowJs": true, "importHelpers": true, - "moduleResolution": "node", - "esModuleInterop": true, "allowSyntheticDefaultImports": true, - "useUnknownInCatchVariables": false, - "resolveJsonModule": true, - "sourceMap": true, "baseUrl": ".", "types": [ "webpack-env", @@ -30,16 +22,14 @@ "dom", "dom.iterable", "scripthost" - ] + ], + // TODO: remove all options below this line + "noUnusedLocals": false, + "useUnknownInCatchVariables": false, }, "include": [ "src/**/*.ts", - "src/**/*.tsx", "src/**/*.vue", "tests/**/*.ts", - "tests/**/*.tsx", - ], - "exclude": [ - "node_modules" ] } diff --git a/packages/node-dev/src/tsconfig-build.json b/packages/node-dev/src/tsconfig-build.json index d118e54eb0679..717db8387a94d 100644 --- a/packages/node-dev/src/tsconfig-build.json +++ b/packages/node-dev/src/tsconfig-build.json @@ -1,21 +1,10 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "lib": [ - "es2017" - ], - "types": [], - "module": "commonjs", "importHelpers": true, - "preserveConstEnums": true, - "declaration": true, - "target": "es2017", - "sourceMap": true }, "include": [ "*.credentials.ts", "*.node.ts" - ], - "exclude": [ - "node_modules" ] } diff --git a/packages/node-dev/tsconfig.json b/packages/node-dev/tsconfig.json index 7e3845accb67f..a1e7bca1dbbaa 100644 --- a/packages/node-dev/tsconfig.json +++ b/packages/node-dev/tsconfig.json @@ -1,31 +1,17 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "lib": [ - "es2019" - ], + "outDir": "dist", "types": [ "node" ], - "module": "commonjs", - "esModuleInterop": true, - "removeComments": true, - "strict": true, - "preserveConstEnums": true, - "declaration": true, - "outDir": "./dist/", - "target": "es2019", - "useUnknownInCatchVariables": false, - "sourceMap": true + // TODO: remove all options below this line + "noUnusedLocals": false, }, "include": [ "**/*.d.ts", "commands/**/*", "index.ts", "src/**/*" - ], - "exclude": [ - "dist", - "node_modules/**/*", - "**/*.spec.ts" ] } diff --git a/packages/nodes-base/package.json b/packages/nodes-base/package.json index 81262bea02b21..0b63b85c58202 100644 --- a/packages/nodes-base/package.json +++ b/packages/nodes-base/package.json @@ -795,17 +795,16 @@ }, "jest": { "transform": { - "^.+\\.tsx?$": "ts-jest" + "^.+\\.ts$": "ts-jest" }, "testURL": "http://localhost/", - "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", + "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)$", "testPathIgnorePatterns": [ "/dist/", "/node_modules/" ], "moduleFileExtensions": [ "ts", - "tsx", "js", "json" ] diff --git a/packages/nodes-base/tsconfig.json b/packages/nodes-base/tsconfig.json index 2be084bcd7cc8..f766abfceeec4 100644 --- a/packages/nodes-base/tsconfig.json +++ b/packages/nodes-base/tsconfig.json @@ -1,23 +1,18 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { + "outDir": "dist", "lib": [ "dom", - "es2019" + "es2020" ], "types": [ "node", "jest" ], - "module": "commonjs", - "removeComments": true, - "strict": true, - "preserveConstEnums": true, - "resolveJsonModule": true, - "declaration": true, - "outDir": "./dist/", - "target": "es2019", - "sourceMap": true, - "esModuleInterop": true, + // TODO: remove all options below this line + "noImplicitReturns": false, + "noUnusedLocals": false, "useUnknownInCatchVariables": false, }, "include": [ @@ -27,8 +22,5 @@ "nodes/**/*.json", "credentials/translations/**/*.json", "test/**/*" - ], - "exclude": [ - "**/*.spec.ts" ] } diff --git a/packages/workflow/package.json b/packages/workflow/package.json index 79d0caf2b4de4..7a3ebffa2bf50 100644 --- a/packages/workflow/package.json +++ b/packages/workflow/package.json @@ -62,17 +62,16 @@ }, "jest": { "transform": { - "^.+\\.tsx?$": "ts-jest" + "^.+\\.ts$": "ts-jest" }, "testURL": "http://localhost/", - "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?)$", + "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(js|ts)$", "testPathIgnorePatterns": [ "/dist/", "/node_modules/" ], "moduleFileExtensions": [ "ts", - "tsx", "js", "json" ] diff --git a/packages/workflow/tsconfig.json b/packages/workflow/tsconfig.json index 5f9568d9cc260..2635204e53063 100644 --- a/packages/workflow/tsconfig.json +++ b/packages/workflow/tsconfig.json @@ -1,36 +1,17 @@ { + "extends": "../../tsconfig.json", "compilerOptions": { - "lib": [ - "dom", - "es2019" - ], + "outDir": "dist", "types": [ "node", "jest" ], - "module": "commonjs", - "removeComments": true, - "forceConsistentCasingInFileNames": true, - "esModuleInterop": true, - "noImplicitReturns": true, - "strict": true, - "noUnusedLocals": true, - "preserveConstEnums": true, - "declaration": true, - "outDir": "./dist/", - "target": "es2019", - "moduleResolution": "node", - "sourceMap": true, + // TODO: remove all options below this line "useUnknownInCatchVariables": false, }, "include": [ "**/*.d.ts", "src/**/*", "test/**/*" - ], - "exclude": [ - "dist/**/*", - "node_modules/**/*", - "**/*.spec.ts" ] } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000000..6da147898cb8f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "strict": true, + "module": "commonjs", + "moduleResolution": "node", + "target": "es2019", + "lib": [ + "es2019", + "es2020", + ], + "removeComments": true, + "useUnknownInCatchVariables": true, + "forceConsistentCasingInFileNames": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noUnusedLocals": true, + "strictNullChecks": true, + "preserveConstEnums": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "declaration": true, + "sourceMap": true, + }, + "exclude": [ + "**/dist/**/*", + "**/node_modules/**/*", + ] +}