From 206cd6ee78c9e2e4cbf54e7821589df1bbc7f346 Mon Sep 17 00:00:00 2001 From: PalmDevs Date: Sat, 5 Apr 2025 18:17:06 +0700 Subject: [PATCH] chore: move types and base tsconfig into separate package --- bun.lock | 8 ++++++ lib/types/internal/tsconfig.json | 21 +++++++++++++++ .../types/internal/types.d.ts | 7 ----- lib/types/package.json | 16 +++++++++++ lib/types/tsconfig.json | 20 ++++++++++++++ types.d.ts => lib/types/types.d.ts | 7 +++++ scripts/tsconfig.json | 23 +--------------- tsconfig.json | 27 ++----------------- 8 files changed, 75 insertions(+), 54 deletions(-) create mode 100644 lib/types/internal/tsconfig.json rename types.internal.d.ts => lib/types/internal/types.d.ts (55%) create mode 100644 lib/types/package.json create mode 100644 lib/types/tsconfig.json rename types.d.ts => lib/types/types.d.ts (96%) diff --git a/bun.lock b/bun.lock index 951829e..5378d08 100644 --- a/bun.lock +++ b/bun.lock @@ -29,10 +29,16 @@ }, "lib/modules": { "name": "@revenge-mod/modules", + "dependencies": { + "@revenge-mod/types": "workspace:*", + }, }, "lib/patcher": { "name": "@revenge-mod/patcher", }, + "lib/types": { + "name": "@revenge-mod/types", + }, "lib/utils": { "name": "@revenge-mod/utils", }, @@ -411,6 +417,8 @@ "@revenge-mod/patcher": ["@revenge-mod/patcher@workspace:lib/patcher"], + "@revenge-mod/types": ["@revenge-mod/types@workspace:lib/types"], + "@revenge-mod/utils": ["@revenge-mod/utils@workspace:lib/utils"], "@rolldown/binding-darwin-arm64": ["@rolldown/binding-darwin-arm64@1.0.0-beta.7-commit.eeb1005", "", { "os": "darwin", "cpu": "arm64" }, "sha512-WQVJ5ArMFTa4p3TlinFrHlBoKOq1cLSp2uWUpws7cwfpJto3ecGiQJnbbRI8RaDaoS9grare9DrimrKIYPs91w=="], diff --git a/lib/types/internal/tsconfig.json b/lib/types/internal/tsconfig.json new file mode 100644 index 0000000..a0b50ab --- /dev/null +++ b/lib/types/internal/tsconfig.json @@ -0,0 +1,21 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + // Features + "lib": ["ESNext"], + "module": "ESNext", + "target": "ES2015", + // Bundler + "moduleResolution": "bundler", + "verbatimModuleSyntax": true, + "noEmit": true, + // Type checking + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noPropertyAccessFromIndexSignature": false, + "types": ["@revenge-mod/types", "@revenge-mod/types/internal/types.d.ts"] + } +} diff --git a/types.internal.d.ts b/lib/types/internal/types.d.ts similarity index 55% rename from types.internal.d.ts rename to lib/types/internal/types.d.ts index 22975a5..2b6c118 100644 --- a/types.internal.d.ts +++ b/lib/types/internal/types.d.ts @@ -1,12 +1,5 @@ // Type definitions for things in this codebase ONLY! -import type { Buffer as _Buffer } from 'buffer' - -declare global { - // Discord has a Buffer polyfill that gets initialized a little later, be careful with this - var Buffer: typeof _Buffer -} - declare global { const __BUILD_ENV__: 'development' | 'production' const __BUILD_COMMIT__: string diff --git a/lib/types/package.json b/lib/types/package.json new file mode 100644 index 0000000..cf70e84 --- /dev/null +++ b/lib/types/package.json @@ -0,0 +1,16 @@ +{ + "name": "@revenge-mod/types", + "private": true, + "type": "module", + "exports": { + "./*": { + "types": "./*" + }, + ".": { + "types": "./types.d.ts" + }, + "./tsconfig": { + "default": "./tsconfig.json" + } + } +} diff --git a/lib/types/tsconfig.json b/lib/types/tsconfig.json new file mode 100644 index 0000000..3af944c --- /dev/null +++ b/lib/types/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + // Features + "lib": ["ESNext"], + "module": "ESNext", + "target": "ES2015", + // Bundler + "moduleResolution": "bundler", + "verbatimModuleSyntax": true, + "noEmit": true, + // Type checking + "strict": true, + "skipLibCheck": true, + "noFallthroughCasesInSwitch": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noPropertyAccessFromIndexSignature": false, + "types": ["@revenge-mod/types"] + } +} diff --git a/types.d.ts b/lib/types/types.d.ts similarity index 96% rename from types.d.ts rename to lib/types/types.d.ts index 00394e1..08d3d8f 100644 --- a/types.d.ts +++ b/lib/types/types.d.ts @@ -1,6 +1,7 @@ // All of these typings are exported, be careful what you export here! import type { Metro } from '@revenge-mod/modules' +import type { Buffer as _Buffer } from 'buffer' import type { ErrorUtils as RNErrorUtils } from 'react-native' /// HERMES @@ -85,6 +86,12 @@ declare global { const ErrorUtils: RNErrorUtils } +/// POLYFILLS + +declare global { + var Buffer: typeof _Buffer +} + export namespace ReactNative { namespace AssetsRegistry { export type AssetDestPathResolver = 'android' | 'generic' diff --git a/scripts/tsconfig.json b/scripts/tsconfig.json index 332cbe4..77b5014 100644 --- a/scripts/tsconfig.json +++ b/scripts/tsconfig.json @@ -1,24 +1,3 @@ { - "compilerOptions": { - // Enable latest features - "lib": ["ESNext"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false, - // Other options - "types": [] - } + "extends": "@revenge-mod/types/tsconfig" } diff --git a/tsconfig.json b/tsconfig.json index 1fda367..d1d1556 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,27 +1,4 @@ { - "compilerOptions": { - // Enable latest features - "lib": ["ESNext", "DOM"], - "target": "ESNext", - "module": "ESNext", - "moduleDetection": "force", - "jsx": "react-jsx", - "allowJs": true, - // Bundler mode - "moduleResolution": "bundler", - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, - "noEmit": true, - // Best practices - "strict": true, - "skipLibCheck": true, - "noFallthroughCasesInSwitch": true, - // Some stricter flags (disabled by default) - "noUnusedLocals": false, - "noUnusedParameters": false, - "noPropertyAccessFromIndexSignature": false, - // Other options - "types": [] - }, - "exclude": ["scripts/**"] + "extends": "@revenge-mod/types/internal/tsconfig.json", + "exclude": ["scripts"] }