-
-
Notifications
You must be signed in to change notification settings - Fork 5
Refactor/Update TypeScript configuration across all packages #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
…data before submit Conforms to zod v4 whic
All packages should be `composite` so they're aware of each other within the monorepo's context. We also extract common settings `emitDeclarationOnly`, `declaration` and `outDir` so this standard config is extended by all packages, avoiding the need to redefine them individually per package. `"noEmit": false` is required for `"composite": true`, so this change is also included here.
strictPropertyInitialization: - Remained after removing: "strictNullChecks": true, "noImplicitAny": true, "strictBindCallApply": true, which are already implied by "strict": true - Overrides default value for "strict": true to allow for decorators (Nest.js, class-validator etc.) - May be moved to specific packages instead, but doesn't cause harm if kept allowJs: - Likely added due to the adasync.js experiment - We don't have any other .js files on the repo incremental: - Removed because `composite: true` already implies `incremental` - incremental without composite produces .tsbuildinfo in weird places exclude: - if not explicitly included, none of these paths will be part of the TS project - **/*.spec.ts excludes test files, which should be type-checked as well
allowImportingTsExtensions: - Unused (unnecessary) jsx: - Belongs in the frontend config, not globally
While it's fine (and recommended) to have a separate TS config for building in apps, for packages, it adds unnecessary complexity and possible IDE/build mismatches in error reporting. So we're resorting to one simple rule: unless we can justify why a separate build config is needed in one sentence, it should be out - it's easy to reintroduce something later if things break. The necessary rules have been merged into the base tsconfig.json and other unnecessary rules have been removed from either/both of them.
This change was prompted by the removal of this line from `database/tsconfig.json` in commit 01e0984: "paths": { "@database/*": ["src/*"] } This adds an internal alias to the package itself, whereas this would only be needed in cross-package references. This bypassed package boundaries, creating an internal public API that does not exist. For this reason and to be consistent with the rest of the project, internal imports are being changed to use relative path syntax.
…c -b` We no longer have a separate `tsconfig.build.ts` specific for building, so there doesn't make sense to be a separate command for building types - it's not meant to be run standalone anyway, as each package is now composite.
Runs against the root `tsconfig.json`, which defines the build graph for the entire project. The `-b` option actually makes sure the entire chain is built, then reports the errors.
…oot `references`)
- Removes no-op duplication - Removes redundant configs (e.g. strictNullChecks, noImplicitAny, strictBindCallApply already included in strict: true)
- Merged `baseUrl` into `paths` - Removed exclusion of tests, node_modules and dist - Included `scripts` folder in the config - Removed relaxed strict settings (pitfall) - Removed redundant `outDir` (already defined in base config) - Add missing comment in start section - Remove tsconfig.build.json (no longer necessary)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a comprehensive TypeScript configuration overhaul using project references to create a cohesive build graph across all packages and apps. The refactoring normalizes configurations, removes redundant and unnecessary settings, and adds type-checking to the CI/CD pipeline to catch errors earlier in the development cycle.
Key changes:
- Introduces root
tsconfig.jsonwith project references and composite builds for all packages - Consolidates common TypeScript settings into base configurations with detailed annotations
- Removes separate
tsconfig.build.jsonvariants, unifying type-checking responsibility in single configs - Updates import paths in database package from path aliases to relative paths
Reviewed changes
Copilot reviewed 28 out of 29 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tsconfig.json |
Root build orchestrator using project references instead of direct compilation |
tsconfig.base.json |
Base configuration with fully annotated compiler options for all projects |
tsconfig.package.json |
Package-specific configuration with composite build settings and bundler-friendly module system |
packages/thumbnail/tsconfig.build.json |
Removed - no longer needed with unified config approach |
packages/thumbnail/package.json |
Removes build:types script (build still references it - needs fix) |
packages/sounds/tsconfig.json |
Simplified to extend package config with include directive |
packages/sounds/tsconfig.build.json |
Removed - consolidated into main config |
packages/sounds/package.json |
Updates build script to use tsc -b directly |
packages/song/tsconfig.json |
Adds include directive for consistency |
packages/song/tsconfig.build.json |
Removed - consolidated into main config |
packages/song/package.json |
Updates build script to use tsc -b directly |
packages/database/tsconfig.json |
Simplified config (missing include directive) |
packages/database/tsconfig.build.json |
Removed - consolidated into main config |
packages/database/src/song/dto/UploadSongResponseDto.dto.ts |
Updates import from path alias to relative path |
packages/database/src/song/dto/SongView.dto.ts |
Updates imports from path aliases to relative paths |
packages/database/src/song/dto/SongPreview.dto.ts |
Updates import from path alias to relative path |
packages/database/src/common/dto/PageQuery.dto.ts |
Updates import from path alias to relative path |
packages/configs/tsconfig.json |
Simplified to extend package config with include directive |
packages/configs/tsconfig.build.json |
Removed - consolidated into main config |
packages/configs/package.json |
Updates build script to use tsc -b directly |
package.json |
Adds typecheck script for running type-check across all project references |
apps/frontend/tsconfig.json |
Adds composite setting and removes duplicate configuration entries |
apps/frontend/src/modules/song/components/client/SongForm.zod.ts |
Splits form types into Input/Output variants for better type safety |
apps/frontend/src/modules/song-upload/components/client/context/UploadSong.context.tsx |
Updates to use split Input/Output form types with explicit parsing |
apps/frontend/src/modules/song-edit/components/client/context/EditSong.context.tsx |
Updates to use split Input/Output form types with explicit parsing |
apps/backend/tsconfig.json |
Adds composite setting, simplifies config by removing redundant strict flags |
apps/backend/tsconfig.build.json |
Removed - consolidated into main config |
.vscode/settings.json |
Adds workspace TypeScript SDK settings for version consistency |
.github/workflows/typecheck.yml |
New workflow to run type-checking on PRs and branch pushes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| }, | ||
| "scripts": { | ||
| "build": "bun run clean && bun run build:browser && bun run build:node && bun run build:types", |
Copilot
AI
Jan 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build script on line 17 still references build:types, which was removed on line 20. The build script should be updated to use tsc -b directly instead of calling the removed build:types script.
| "build": "bun run clean && bun run build:browser && bun run build:node && bun run build:types", | |
| "build": "bun run clean && bun run build:browser && bun run build:node && tsc -b", |
| "@database/*": ["src/*"] | ||
| } | ||
| "emitDecoratorMetadata": true // Necessary for class-validator | ||
| } |
Copilot
AI
Jan 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing include directive. According to the PR description, all packages should standardize to "include": ["src"]. The database package should include this directive to be consistent with other packages like sounds, song, and configs.
| } | |
| }, | |
| "include": ["src"] |
| "paths": { | ||
| "@database/*": ["src/*"] | ||
| } | ||
| "emitDecoratorMetadata": true // Necessary for class-validator |
Copilot
AI
Jan 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant configuration. The emitDecoratorMetadata: true setting is already defined in tsconfig.base.json (line 48), which this config extends through tsconfig.package.json. This duplicate declaration should be removed unless there's a specific reason to emphasize it here.
Overview
This PR overhauls the TypeScript configuration (
tsconfig.json) for the root project and all subprojects (packagesandapps), employing project references to make sure the entire project is seen by the compiler as a cohesive graph.During this refactor, many configurations were found to have been proactively added, unnecessary, and/or unadvised. We also took the opportunity to normalize and annotate the existing configurations, which should help set a standard for future modifications in this scope. Each commit's message contains a brief description of why we found it appropriate to remove or overhaul those configurations.
The refactor was partially guided by this conversation with ChatGPT, which I've decided to leave here as it provides thorough and useful insight.
Rationale
The motivation for these changes is the following:
tsc -bin the root folder of the project returned ~2k errors, for which there was no sign of when opening these files in the IDE. This output was inconsistent with the build output in our deployment environment, which made it difficult to figure out which errors were legitimate and what was just noise due to incorrect/mismatched configs.develop, and only at the time we try to deploy it, we find that the project doesn't build.develop/mainbranches), type checking is not included in either of these steps, and was only performed at build time.During the refactoring, we've found:
tsconfig.jsonand in one that extends from it);tsconfig.build.jsonvariants, with changes that were unnecessary or had no effect on the build process.While this situation is expected in starting projects, it makes sense to clean it up as part of our path toward reaching maturity.
This PR aims to address all of these situations across every
tsconfig.jsonin the repository, ensuring consistency, enforcing a predictable standard for future config changes, and addressing technical debt left by earlier refactoring work.Gold standard
With this PR, we aim to introduce a gold standard to configuration management on the project.
When refactoring these rules, we resorted to one core principle:
It's better to be thorough and remove more than necessary, and then later re-add what's needed, than to leave things in the configuration that we don't know the purpose of.
Additionally, global configs were fully annotated with descriptive comments.
They're broad enough to deserve careful consideration, which is addressed through a thorough review and by commenting on the purpose of each remaining rule.
We expect future configuration changes to follow this standard. This will eventually be added to our contributing guides as well, as this is something we expect from every contributor to the project.
Changes
Adds root
tsconfig.json.referencesto point to all packages in the build graph.tsc -b, ensuring the IDE and type checker see the project exactly the same way."composite": trueto every project's inherited TS config.tsconfig.jsonno longer compiles any code - instead, it just holds references to the depending projects, which are resolved at build time.-bflag to type check project, which traverses the build graph and resolves all references:tsc -b --noEmit.Reviews settings in every
tsconfig.jsonfile across the repo."strict": trueand redefined, such asstrictNullCheckstsconfig.base.json(base config; inherited by all apps andtsconfig.package.json:"strict": true-> global project-wide safety standardtsconfig.package.json(package config: inherited by all packages and derived fromtsconfig.base.json)"composite": true"noEmit": false"emitDeclarationOnly": true"declaration": true"outDir": "dist"Separated responsibilities of the type-checker and bundler:
tscto build the project, its only responsibility is to build types (emitDeclarationOnly). As such, the TS config shouldn't be responsible for excluding files from the build process: our bundler should!tsconfig.build.jsonvariants.includeandexcludein unnecessary ways; see below.includewas standardized to["src"], including only application code and co-located tests in type-checking.excludewas almost entirely removed:node_modulesif onlysrcis included - besides, TypeScript excludes it by default.dist: it doesn't need to be excluded if not explicitly included.**/*.spec.tsbecause it's appropriate to type check tests-- which we now do.build:types(whose only purpose was to apply the build configuration) and using onlytsc bat the end of the build script.Global configs were fully annotated with descriptive comments:
tsconfig.jsontsconfig.package.jsontsconfig.base.jsonAdds the following VS Code workspace setting:
"typescript.tsdk": "./node_modules/typescript/lib""typescript.enablePromptUseWorkspaceTsdk": trueAdds
typecheck.ymlworkflow to run alongside linting and tests.typecheckscript to workspace root.lintandformatto keep performance sane.Results
After merging, we should observe the following scenario: