From 2778b20ca36ac3c864a0fe1bba2b89e86fbcf8a5 Mon Sep 17 00:00:00 2001 From: Rahim Date: Thu, 30 Oct 2025 02:55:17 +0000 Subject: [PATCH] chore(packages): move dom types down --- packages/core/tsconfig.json | 2 ++ packages/html/tsconfig.json | 1 + packages/react/package.json | 1 + packages/react/svgr.config.js | 1 + packages/react/tsconfig.json | 1 + packages/utils/src/dom/tsconfig.json | 8 ++++++++ packages/utils/src/shared/state.ts | 2 +- packages/utils/src/shared/time.ts | 9 ++++----- packages/utils/tsconfig.json | 2 ++ pnpm-lock.yaml | 3 +++ tsconfig.base.json | 2 +- 11 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 packages/utils/src/dom/tsconfig.json diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index e7ad53e0..e7f0c314 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -1,6 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + // This will be removed. + "lib": ["ES2020", "DOM", "DOM.Iterable"], "baseUrl": ".", "paths": { "@/*": ["src/*"] diff --git a/packages/html/tsconfig.json b/packages/html/tsconfig.json index e7ad53e0..91cf2438 100644 --- a/packages/html/tsconfig.json +++ b/packages/html/tsconfig.json @@ -1,6 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "lib": ["ES2020", "DOM", "DOM.Iterable"], "baseUrl": ".", "paths": { "@/*": ["src/*"] diff --git a/packages/react/package.json b/packages/react/package.json index efa10c4b..5d5eaf78 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -63,6 +63,7 @@ "devDependencies": { "@svgr/babel-plugin-add-jsx-attribute": "^8.0.0", "@svgr/cli": "^8.1.0", + "@svgr/core": "^8.1.0", "@svgr/plugin-jsx": "^8.1.0", "@tailwindcss/cli": "^4.1.0", "@types/postcss-prefix-selector": "^1.16.3", diff --git a/packages/react/svgr.config.js b/packages/react/svgr.config.js index e6c56344..6ccbe482 100644 --- a/packages/react/svgr.config.js +++ b/packages/react/svgr.config.js @@ -1,5 +1,6 @@ import path from 'node:path'; +/** @type {import('@svgr/core').Config & { indexTemplate: (filePaths: { path: string }[]) => string }} */ export default { plugins: ['@svgr/plugin-jsx'], typescript: true, diff --git a/packages/react/tsconfig.json b/packages/react/tsconfig.json index 510f986e..f1157ea6 100644 --- a/packages/react/tsconfig.json +++ b/packages/react/tsconfig.json @@ -3,6 +3,7 @@ "compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "react", + "lib": ["ES2020", "DOM", "DOM.Iterable"], "baseUrl": ".", "paths": { "@/*": ["src/*"] diff --git a/packages/utils/src/dom/tsconfig.json b/packages/utils/src/dom/tsconfig.json new file mode 100644 index 00000000..fdae4c67 --- /dev/null +++ b/packages/utils/src/dom/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "composite": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"] + }, + "include": ["./**/*.ts"] +} diff --git a/packages/utils/src/shared/state.ts b/packages/utils/src/shared/state.ts index d72bec3d..8ce3c436 100644 --- a/packages/utils/src/shared/state.ts +++ b/packages/utils/src/shared/state.ts @@ -3,7 +3,7 @@ * so we may treat them specifically as unequal if they are not a) both arrays * or b) don't contain the same (shallowly compared) elements. */ -export function shallowEqual(objA: any, objB: any): boolean { +export function shallowEqual(objA: object, objB: object): boolean { // Using Object.is as a first pass, as it covers a lot of the "simple" cases that are // more complex than strict equality and is a built-in. For discussion, see, e.g.: // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is#description diff --git a/packages/utils/src/shared/time.ts b/packages/utils/src/shared/time.ts index 466b93b1..251476ed 100644 --- a/packages/utils/src/shared/time.ts +++ b/packages/utils/src/shared/time.ts @@ -1,9 +1,8 @@ - /** * Checks if a value is a valid number (not NaN, null, undefined, or Infinity) */ function isValidNumber(value: unknown): value is number { - return typeof value === 'number' && isFinite(value); + return typeof value === 'number' && Number.isFinite(value); } const UnitLabels = [ @@ -29,7 +28,7 @@ function toTimeUnitPhrase(timeUnitValue: number, unitIndex: number): string { /** * Converts numeric seconds into a human-readable phrase for accessibility. - * + * * @param seconds - A (positive or negative) time, represented as seconds * @returns The time, represented as a phrase of hours, minutes, and seconds * @@ -96,7 +95,7 @@ export function formatTime(seconds: number, guide?: number): string { const gh = guide ? Math.floor(guide / 3600) : 0; // Handle invalid times - if (isNaN(seconds) || seconds === Infinity) { + if (Number.isNaN(seconds) || seconds === Infinity) { // '-' is false for all relational operators (e.g. <, >=) so this setting // will add the minimum number of fields specified by the guide h = m = s = '0'; @@ -118,7 +117,7 @@ export function formatTime(seconds: number, guide?: number): string { /** * Formats a time value with fallback handling for invalid values. - * + * * @param time - The time value to format in seconds (duration, currentTime, etc.) * @param guide - Optional guide time for consistent formatting * @param fallback - Fallback text when time is invalid (default: "--:--") diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json index e7ad53e0..4a567e27 100644 --- a/packages/utils/tsconfig.json +++ b/packages/utils/tsconfig.json @@ -1,10 +1,12 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "composite": true, "baseUrl": ".", "paths": { "@/*": ["src/*"] } }, + "references": [{ "path": "./src/dom" }], "include": ["src"] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a8f440f9..24e82aea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -211,6 +211,9 @@ importers: '@svgr/cli': specifier: ^8.1.0 version: 8.1.0(typescript@5.9.3) + '@svgr/core': + specifier: ^8.1.0 + version: 8.1.0(typescript@5.9.3) '@svgr/plugin-jsx': specifier: ^8.1.0 version: 8.1.0(@svgr/core@8.1.0(typescript@5.9.3)) diff --git a/tsconfig.base.json b/tsconfig.base.json index f4e38aee..b1a69a96 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -3,7 +3,7 @@ "incremental": true, "composite": true, "target": "ES2020", - "lib": ["ES2020", "DOM", "DOM.Iterable"], + "lib": ["ES2020"], "module": "ESNext", "moduleResolution": "bundler", "resolveJsonModule": true,