From d2f69b53016b35310f90081d0fa3630c273f057e Mon Sep 17 00:00:00 2001 From: Ira Hopkinson Date: Wed, 28 Aug 2024 15:35:00 +1200 Subject: [PATCH] - more code review - also make VS Code use the repo TS version --- .vscode/settings.json | 1 + extensions/src/c-sharp-provider-test/index.d.ts | 1 + .../src/hello-someone/src/types/hello-someone.d.ts | 1 + extensions/src/hello-world/src/types/hello-world.d.ts | 1 + .../platform-scripture/src/types/platform-scripture.d.ts | 1 + extensions/src/project-notes-data-provider/index.d.ts | 1 + extensions/src/quick-verse/src/types/quick-verse.d.ts | 1 + .../@types/@senojs-rollup-plugin-style-inject.d.ts | 9 --------- lib/platform-bible-react/package.json | 2 +- lib/platform-bible-react/tsconfig.json | 2 +- lib/platform-bible-react/tsconfig.lint.json | 5 +---- lib/platform-bible-utils/package.json | 2 +- lib/platform-bible-utils/tsconfig.lint.json | 3 --- package.json | 4 ++-- ....ts => platform-dock-layout-positioning.util.test.ts} | 0 tsconfig.json | 5 +++-- tsconfig.lint.json | 4 ---- 17 files changed, 16 insertions(+), 27 deletions(-) delete mode 100644 lib/platform-bible-react/@types/@senojs-rollup-plugin-style-inject.d.ts rename src/renderer/components/docking/{platform-dock-layout-positioning.util.tests.ts => platform-dock-layout-positioning.util.test.ts} (100%) diff --git a/.vscode/settings.json b/.vscode/settings.json index bd77250cdf..b52b788974 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -23,6 +23,7 @@ "javascript.validate.enable": false, "javascript.format.enable": false, "typescript.format.enable": false, + "typescript.tsdk": "node_modules/typescript/lib", "search.exclude": { ".git": true, diff --git a/extensions/src/c-sharp-provider-test/index.d.ts b/extensions/src/c-sharp-provider-test/index.d.ts index a98f1025e4..4f9736d330 100644 --- a/extensions/src/c-sharp-provider-test/index.d.ts +++ b/extensions/src/c-sharp-provider-test/index.d.ts @@ -1,4 +1,5 @@ declare module 'c-sharp-provider-test' { + // @ts-ignore: TS2307 - Cannot find module '@papi/core' or its corresponding type declarations import { IDataProvider, DataProviderDataType } from '@papi/core'; type TimeDataTypes = { diff --git a/extensions/src/hello-someone/src/types/hello-someone.d.ts b/extensions/src/hello-someone/src/types/hello-someone.d.ts index e96fb9a93e..ebac819be2 100644 --- a/extensions/src/hello-someone/src/types/hello-someone.d.ts +++ b/extensions/src/hello-someone/src/types/hello-someone.d.ts @@ -1,4 +1,5 @@ declare module 'hello-someone' { + // @ts-ignore: TS2307 - Cannot find module '@papi/core' or its corresponding type declarations import { IDataProvider, DataProviderDataType } from '@papi/core'; export type Person = { diff --git a/extensions/src/hello-world/src/types/hello-world.d.ts b/extensions/src/hello-world/src/types/hello-world.d.ts index 412ee19c3a..ff6232375b 100644 --- a/extensions/src/hello-world/src/types/hello-world.d.ts +++ b/extensions/src/hello-world/src/types/hello-world.d.ts @@ -1,4 +1,5 @@ declare module 'hello-world' { + // @ts-ignore: TS2307 - Cannot find module '@papi/core' or its corresponding type declarations import type { DataProviderDataType, MandatoryProjectDataTypes } from '@papi/core'; import type { IBaseProjectDataProvider } from 'papi-shared-types'; diff --git a/extensions/src/platform-scripture/src/types/platform-scripture.d.ts b/extensions/src/platform-scripture/src/types/platform-scripture.d.ts index 3b0a68914f..61becd6f5c 100644 --- a/extensions/src/platform-scripture/src/types/platform-scripture.d.ts +++ b/extensions/src/platform-scripture/src/types/platform-scripture.d.ts @@ -6,6 +6,7 @@ declare module 'platform-scripture' { DataProviderUpdateInstructions, ExtensionDataScope, IDataProvider, + // @ts-ignore: TS2307 - Cannot find module '@papi/core' or its corresponding type declarations } from '@papi/core'; import type { IProjectDataProvider } from 'papi-shared-types'; import { Dispose, LocalizeKey, UnsubscriberAsync } from 'platform-bible-utils'; diff --git a/extensions/src/project-notes-data-provider/index.d.ts b/extensions/src/project-notes-data-provider/index.d.ts index b1b1a174ad..528459fa78 100644 --- a/extensions/src/project-notes-data-provider/index.d.ts +++ b/extensions/src/project-notes-data-provider/index.d.ts @@ -3,6 +3,7 @@ import type { DataProviderDataType, DataProviderSubscriberOptions, IDataProvider, + // @ts-ignore: TS2307 - Cannot find module '@papi/core' or its corresponding type declarations } from '@papi/core'; import { PlatformEvent, Unsubscriber } from 'platform-bible-utils'; diff --git a/extensions/src/quick-verse/src/types/quick-verse.d.ts b/extensions/src/quick-verse/src/types/quick-verse.d.ts index 451747d5c3..205520b507 100644 --- a/extensions/src/quick-verse/src/types/quick-verse.d.ts +++ b/extensions/src/quick-verse/src/types/quick-verse.d.ts @@ -1,4 +1,5 @@ declare module 'quick-verse' { + // @ts-ignore: TS2307 - Cannot find module '@papi/core' or its corresponding type declarations import { DataProviderDataType, IDataProvider } from '@papi/core'; export type QuickVerseSetData = string | { text: string; isHeresy: boolean }; diff --git a/lib/platform-bible-react/@types/@senojs-rollup-plugin-style-inject.d.ts b/lib/platform-bible-react/@types/@senojs-rollup-plugin-style-inject.d.ts deleted file mode 100644 index b1b8e187c7..0000000000 --- a/lib/platform-bible-react/@types/@senojs-rollup-plugin-style-inject.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare module '@senojs/rollup-plugin-style-inject' { - type StyleInjectOptions = { - insertAt?: 'top' | 'bottom'; - }; - - // This should return `PluginOption` type from vite but this is only build config. - // eslint-disable-next-line @typescript-eslint/no-explicit-any - export default function styleInject(options?: StyleInjectOptions): any; -} diff --git a/lib/platform-bible-react/package.json b/lib/platform-bible-react/package.json index e5220fa37d..7df49a38b1 100644 --- a/lib/platform-bible-react/package.json +++ b/lib/platform-bible-react/package.json @@ -40,7 +40,7 @@ "lint-fix": "npm run lint-fix:scripts && npm run lint:styles -- --fix", "lint-fix:scripts": "prettier --write \"**/*.{ts,tsx,js,jsx,cjs}\" && npm run lint:scripts", "test": "jest --silent", - "typecheck": "tsc -p ./tsconfig.lint.json" + "typecheck": "tsc -p ./tsconfig.json" }, "peerDependencies": { "react": ">=18.2.0", diff --git a/lib/platform-bible-react/tsconfig.json b/lib/platform-bible-react/tsconfig.json index 6272dcafd7..af0da8fb01 100644 --- a/lib/platform-bible-react/tsconfig.json +++ b/lib/platform-bible-react/tsconfig.json @@ -9,7 +9,7 @@ // directories looking for node_modules/@types folders by default. // We needed to remove react from here below because having two copies was causing problems in // the jest tests. But we need the types in both places. - "typeRoots": ["./node_modules/@types", "../../node_modules/@types", "./@types"], + "typeRoots": ["./node_modules/@types", "../../node_modules/@types"], "lib": ["ESNext", "DOM", "DOM.Iterable"], "forceConsistentCasingInFileNames": true, "incremental": false, diff --git a/lib/platform-bible-react/tsconfig.lint.json b/lib/platform-bible-react/tsconfig.lint.json index 7afbd5f608..468dd5a784 100644 --- a/lib/platform-bible-react/tsconfig.lint.json +++ b/lib/platform-bible-react/tsconfig.lint.json @@ -1,7 +1,4 @@ { "extends": "./tsconfig", - "compilerOptions": { - "skipLibCheck": true - }, - "include": [".eslintrc.cjs", "postcss.config.js", "*.ts", "src", "@types"] + "include": [".eslintrc.cjs", "postcss.config.js", "*.ts", "src"] } diff --git a/lib/platform-bible-utils/package.json b/lib/platform-bible-utils/package.json index 84145dfe13..6fa5cc777e 100644 --- a/lib/platform-bible-utils/package.json +++ b/lib/platform-bible-utils/package.json @@ -37,7 +37,7 @@ "lint-fix": "npm run lint-fix:scripts", "lint-fix:scripts": "prettier --write \"**/*.{ts,tsx,js,jsx,cjs}\" && npm run lint:scripts", "test": "jest --silent", - "typecheck": "tsc -p ./tsconfig.lint.json" + "typecheck": "tsc -p ./tsconfig.json" }, "peerDependencies": {}, "dependencies": { diff --git a/lib/platform-bible-utils/tsconfig.lint.json b/lib/platform-bible-utils/tsconfig.lint.json index 4f7c8e3f03..86b7a99cfd 100644 --- a/lib/platform-bible-utils/tsconfig.lint.json +++ b/lib/platform-bible-utils/tsconfig.lint.json @@ -1,7 +1,4 @@ { "extends": "./tsconfig", - "compilerOptions": { - "skipLibCheck": true - }, "include": [".eslintrc.cjs", "*.ts", "src"] } diff --git a/package.json b/package.json index a304d420ec..2eacf968fd 100644 --- a/package.json +++ b/package.json @@ -87,8 +87,8 @@ "storybook:build": "storybook build", "test": "npm run test:core && npm run test --workspaces --if-present", "test:core": "jest --silent", - "typecheck": "npm run typecheck:core && npm run typecheck:extensions && npm run typecheck:papi-dts && npm run typecheck:platform-bible-utils && npm run typecheck:platform-bible-react", - "typecheck:core": "tsc -p ./tsconfig.lint.json", + "typecheck": "npm run typecheck:core && npm run typecheck --workspaces --if-present", + "typecheck:core": "tsc -p ./tsconfig.json", "typecheck:extensions": "cd extensions && npm run typecheck", "typecheck:papi-dts": "cd lib/papi-dts && npm run typecheck", "typecheck:platform-bible-react": "cd lib/platform-bible-react && npm run typecheck", diff --git a/src/renderer/components/docking/platform-dock-layout-positioning.util.tests.ts b/src/renderer/components/docking/platform-dock-layout-positioning.util.test.ts similarity index 100% rename from src/renderer/components/docking/platform-dock-layout-positioning.util.tests.ts rename to src/renderer/components/docking/platform-dock-layout-positioning.util.test.ts diff --git a/tsconfig.json b/tsconfig.json index 663f916396..d3e1d346bb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,7 +25,7 @@ // Include extensions' type declarations "./extensions/src", // Include additions and overrides - "src/@types" + "./src/@types" ], "allowJs": true, "allowSyntheticDefaultImports": true, @@ -38,9 +38,10 @@ "resolveJsonModule": true, "outDir": ".erb/dll" }, - "include": ["src", "assets"], + "include": ["src", "assets", "!**/*.test.{ts,tsx}"], "exclude": [ "node_modules", + "dist", "test", "release/build", "release/app/dist", diff --git a/tsconfig.lint.json b/tsconfig.lint.json index 2cba1dfdbf..3006d442c9 100644 --- a/tsconfig.lint.json +++ b/tsconfig.lint.json @@ -1,11 +1,7 @@ { "extends": "./tsconfig", - "compilerOptions": { - "skipLibCheck": true - }, "include": [ ".eslintrc.js", - ".eslintrc.cjs", "*.ts", ".erb/configs", ".erb/mocks",