Skip to content

Added typecheck script and TypeScript configuration improvements#25354

Merged
rob-ghost merged 1 commit intomainfrom
feat/typecheck-gitignore-tsconfig
Nov 6, 2025
Merged

Added typecheck script and TypeScript configuration improvements#25354
rob-ghost merged 1 commit intomainfrom
feat/typecheck-gitignore-tsconfig

Conversation

@rob-ghost
Copy link
Contributor

@rob-ghost rob-ghost commented Nov 5, 2025

ref https://linear.app/ghost/issue/BER-2610

Why are we making this change?

We wanted to add an independent typecheck script to validate TypeScript types in the apps/admin package and all new React code being added as part of the Ember → React migration.

The Problem

Initially, we attempted to use tsc --noEmit for type checking, but this doesn't work with TypeScript project references. The apps/admin package uses project references (composite TypeScript configuration) to depend on other packages:

  • apps/admin-x-framework
  • apps/posts
  • apps/stats
  • apps/activitypub

With project references, TypeScript needs to emit .d.ts declaration files from referenced projects so the consuming project can type-check against them. This means we must use tsc -b (build mode) instead of tsc --noEmit.

The Side Effect

When running tsc -b, TypeScript builds all the referenced dependencies and generates their declaration files into types/ directories (as configured in each package's tsconfig.declaration.json). These generated files were appearing as untracked in git.

We found an established pattern in the codebase where packages like admin-x-framework, admin-x-design-system, and shade already have types/ in their .gitignore. This PR extends that pattern to the remaining dependencies.

What does this PR do?

  1. Adds .gitignore entries for generated types/ directories in:

    • apps/activitypub
    • apps/posts
    • apps/stats
  2. Adds typecheck npm script to apps/admin/package.json:

    "typecheck": "tsc -b"
  3. Configures TypeScript path aliases in apps/admin/tsconfig.app.json:

    • @/*./src/*
    • @test-utils/*./test-utils/*
  4. Updates TypeScript includes to include the test-utils directory


Note

Adds a typecheck script, configures TS path aliases and includes in admin, and ignores generated types/ in related apps.

  • TypeScript & Build:
    • Add typecheck script (tsc -b) in apps/admin/package.json.
    • Configure TS path aliases in apps/admin/tsconfig.app.json (@/*, @test-utils/*), include test-utils, and add reference to ../admin-x-framework/tsconfig.declaration.json.
  • Repo hygiene:
    • Ignore generated types/ in .gitignore for apps/activitypub, apps/posts, and apps/stats.

Written by Cursor Bugbot for commit 2d498b1. This will update automatically on new commits. Configure here.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 5, 2025

Walkthrough

This pull request updates configuration and git-ignore files across multiple applications. It adds "types" to the .gitignore files in apps/activitypub, apps/posts, and apps/stats. It adds a new npm script "typecheck": "tsc -b" to apps/admin/package.json. It modifies apps/admin/tsconfig.app.json to add TypeScript path aliases (@/*./src/*, @test-utils/*./test-utils/*), include test-utils, and retain a project reference to ../activitypub/tsconfig.declaration.json.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Homogeneous .gitignore additions are trivial.
  • package.json script addition is straightforward.
  • tsconfig.app.json changes are configuration edits but may require validation.

Areas to check:

  • Confirm the path alias mappings in apps/admin/tsconfig.app.json resolve to the intended directories.
  • Verify the project reference ../activitypub/tsconfig.declaration.json points to a valid config.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding a typecheck script and improving TypeScript configuration in the admin package.
Description check ✅ Passed The description comprehensively explains the motivation, problem, side effects, and all changes made in the PR, directly relating to the changeset.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/typecheck-gitignore-tsconfig

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d498b1 and 6bc6e19.

📒 Files selected for processing (5)
  • apps/activitypub/.gitignore (1 hunks)
  • apps/admin/package.json (1 hunks)
  • apps/admin/tsconfig.app.json (2 hunks)
  • apps/posts/.gitignore (1 hunks)
  • apps/stats/.gitignore (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • apps/activitypub/.gitignore
  • apps/stats/.gitignore
  • apps/admin/package.json
  • apps/admin/tsconfig.app.json
  • apps/posts/.gitignore
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Setup
  • GitHub Check: Build & Push
  • GitHub Check: Setup

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rob-ghost rob-ghost added the test temporary label to try to force ci to run label Nov 5, 2025
@rob-ghost rob-ghost self-assigned this Nov 5, 2025
@rob-ghost rob-ghost force-pushed the feat/typecheck-gitignore-tsconfig branch from eac498b to 2d498b1 Compare November 5, 2025 13:21
@rob-ghost rob-ghost marked this pull request as ready for review November 5, 2025 13:21
Copy link
Member

@jonatansberg jonatansberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall approach looks sound. I have a few comments and questions I'd love feedback on before merging.

"preview": "vite preview",
"test:unit": "vitest run"
"test:unit": "vitest run",
"typecheck": "tsc -b"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you feel about calling this check:types and then adding a separate check command that runs both the linting and the type check (and potentially future formatting checks)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, or check: parallel(format, lint, typecheck) perhaps?

"noUncheckedSideEffectImports": true
},
"include": ["src"],
"include": ["src", "test-utils"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't think we can put this in a separate TS config so we don't end up accidentally importing test things within the main app?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do think we can, I tried it but unfortunately things got messy, specifically around detecting when to use tsconfig.test.json and how to compose that with tsconfig.app.json and tsconfig.node.json but only under test. For example, tsc wouldn't pickup the tests when type-checking without resolving the config.

In the end I walked it back because it was getting too messy. I can try again if we think its worth the investment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this in our mob session and decided it was worth figuring out, but now isn't the time to do it so we'll loop back around once the whats-new work is complete to implement this.

ref https://linear.app/ghost/issue/BER-2610

- Added typecheck npm script for explicit type checking
- Configured TypeScript path aliases (@/* and @test-utils/*)
- Added .gitignore entries for generated types directory in admin apps
@rob-ghost rob-ghost force-pushed the feat/typecheck-gitignore-tsconfig branch from 2d498b1 to 6bc6e19 Compare November 6, 2025 10:47
@cursor
Copy link

cursor bot commented Nov 6, 2025

You have run out of free Bugbot PR reviews for this billing cycle. This will reset on December 3.

To receive reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

Copy link
Member

@jonatansberg jonatansberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed and approved in mob session

@rob-ghost rob-ghost enabled auto-merge (squash) November 6, 2025 10:51
@rob-ghost rob-ghost merged commit 0116267 into main Nov 6, 2025
28 checks passed
@rob-ghost rob-ghost deleted the feat/typecheck-gitignore-tsconfig branch November 6, 2025 10:55
abdultalha0862 pushed a commit to abdultalha0862/Ghost that referenced this pull request Nov 20, 2025
…Ghost#25354)

ref https://linear.app/ghost/issue/BER-2610

Adds test directory support to typescript configuration and typechecking command to admin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test temporary label to try to force ci to run

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants