Skip to content

build: upgrade to native typescript v7 🚀#8357

Open
serhalp wants to merge 2 commits into
mainfrom
serhalp/build/tsgo
Open

build: upgrade to native typescript v7 🚀#8357
serhalp wants to merge 2 commits into
mainfrom
serhalp/build/tsgo

Conversation

@serhalp

@serhalp serhalp commented Jul 24, 2026

Copy link
Copy Markdown
Member

Summary

The native Go rewrite of TypeScript was recently released as stable v7.

This upgrades this repo's build/typechecking tooling from v5 to v7, resulting in a significant speedup in build and typechecking time:

(Each is a median of 5 runs on an Apple M3 Pro, TS invoked directly)

Scenario Operation TS 5.8 Native TS 7 Speedup
Clean (full compile) Typecheck 3.60s 0.62s ~5.8×
Clean (full compile) Build 3.46s 0.68s ~5×
Incremental (no-op) Typecheck 1.28s 0.40s ~3.2×
Incremental (no-op) Build 0.96s 0.24s ~4×

typescript-eslint does not yet support native TS and expects the tsc CLI to be available, so we need to use an alias for now. We'll probably just migrate to oxlint soon anyway.

typescript-eslint does not yet support native TS and expects `tsc` to be available, so we need to
use an alias for now. We'll probably just migrate to oxlint soon anyway.
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR aligns build and typecheck scripts with the native TypeScript compiler, updates TypeScript dependencies, and adjusts compiler configuration. Source changes refine runtime type narrowing, optional access, callback defaults, and value conversion. Unit tests remove redundant type assertions and add targeted lint suppressions for mocked methods.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: eduardoboucas

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: upgrading the build tooling to native TypeScript v7.
Description check ✅ Passed The description is directly related to the changeset and explains the TypeScript v7 upgrade and compatibility rationale.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch serhalp/build/tsgo

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

@github-actions

Copy link
Copy Markdown

📊 Benchmark results

Comparing with f214e69

  • Dependency count: 1,134 ⬆️ 0.62% increase vs. f214e69
  • Package size: 429 MB ⬆️ 11.65% increase vs. f214e69
  • Number of ts-expect-error directives: 358 (no change)

Comment thread src/utils/run-build.ts
env = {},
options,
settings,
timeline = 'build',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Both callers pass a string literal here and the type is already marked as required

Comment thread tsconfig.build.json
"sourceMap": true
"rootDir": "src",
"sourceMap": true,
"tsBuildInfoFile": "./tsconfig.build.tsbuildinfo"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This isn't strictly related, but I noticed that we were publishing this to npm and it's 370 KB (~15% of the package). This fixes that by not writing it to dist/.

@serhalp
serhalp marked this pull request as ready for review July 24, 2026 11:25
@serhalp
serhalp requested a review from a team as a code owner July 24, 2026 11:25

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0cc5c3969

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread package.json
"scripts": {
"_format": "prettier --loglevel=warn \"{src,tools,scripts,tests,e2e,.github}/**/*.{mjs,cjs,js,mts,md,yml,json,html,ts}\" \"*.{mjs,cjs,js,mts,yml,json,html,ts}\" \".*.{mjs,cjs,js,yml,json,html,ts}\" \"!CHANGELOG.md\" \"!**/*/package-lock.json\" \"!.github/**/*.md\"",
"build": "tsc --project tsconfig.build.json",
"build": "node ./node_modules/typescript-native/bin/tsc --project tsconfig.build.json",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Restore ambient @types for the new compiler

When npm run build starts using the TS 7 compiler here, TS 6/7 defaults types to an empty list unless the tsconfig sets it explicitly; this repo's base config only sets typeRoots. In the GitHub workflows I checked, unit-tests, integration-tests, e2e-tests, and release jobs all run npm run build after npm ci, so the build program no longer loads @types/node and fails on the many node:* imports/NodeJS references before emitting dist. Add an explicit types entry (for example node plus any needed ambient packages, or *) before switching the build/typecheck scripts to TS 7.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
src/utils/env/index.ts (1)

195-205: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Reflect the runtime default in the parameter type.

envelopeItems defaults to [], and the upstream API response is explicitly documented as potentially undefined, but the public parameter remains required. Make it optional (or explicitly EnvelopeItem[] | undefined) and remove the suppression once the contract matches runtime behavior.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/utils/env/index.ts` around lines 195 - 205, Update the formatEnvelopeData
parameter type so envelopeItems is optional or explicitly allows undefined,
matching its default [] and upstream response contract. Then remove the
eslint-disable suppression while preserving the existing defaulting and
filtering behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Line 35: Update the package.json clean script to remove
tsconfig.build.tsbuildinfo in addition to the dist/ directory, ensuring both
generated outputs and the TypeScript incremental build cache are deleted.

In `@src/commands/api/api.ts`:
- Around line 14-15: Remove the implementation-describing comment immediately
above the dynamic method-name guard in the API command code, leaving the
existing guard and type definitions unchanged.

In `@src/commands/base-command.ts`:
- Around line 121-122: Update the workspace package-count check in the base
command to retain the nullability guard for workspace.packages before reading
length or indexing the first package. Preserve the existing behavior for
undefined packages while returning the sole package path when packages contains
exactly one entry.

---

Nitpick comments:
In `@src/utils/env/index.ts`:
- Around line 195-205: Update the formatEnvelopeData parameter type so
envelopeItems is optional or explicitly allows undefined, matching its default
[] and upstream response contract. Then remove the eslint-disable suppression
while preserving the existing defaulting and filtering behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1ad53d8d-acf4-4458-9c53-c2d67aa7c1e7

📥 Commits

Reviewing files that changed from the base of the PR and between 8943e38 and f0cc5c3.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (19)
  • .gitignore
  • package.json
  • src/commands/api/api.ts
  • src/commands/base-command.ts
  • src/commands/database/util/psql-formatter.ts
  • src/commands/env/env.ts
  • src/commands/logs/sources/edge-functions.ts
  • src/lib/functions/netlify-function.ts
  • src/utils/deploy/drop-api.ts
  • src/utils/deploy/upload-source-zip.ts
  • src/utils/env/index.ts
  • src/utils/run-build.ts
  • tests/unit/commands/database/db-status.test.ts
  • tests/unit/commands/login/login-check.test.ts
  • tests/unit/commands/login/login-request.test.ts
  • tests/unit/recipes/ai-context/download-context-files.test.ts
  • tests/unit/utils/live-tunnel.test.ts
  • tsconfig.base.json
  • tsconfig.build.json
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • netlify/blueprints (manual)
💤 Files with no reviewable changes (1)
  • tsconfig.base.json

Comment thread package.json
Comment thread src/commands/api/api.ts
Comment thread src/commands/base-command.ts

@sarahetter sarahetter left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

a few nits 🙏

Comment thread src/commands/api/api.ts
const isValidApiMethod = (api: NetlifyAPI, apiMethod: string): apiMethod is ApiMethodName =>
Object.hasOwn(api, apiMethod)

// The method name comes from CLI args, so the value is read dynamically (as `unknown`); this guard

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"single, honest call signature"? HUH? decomment-slop pls 🙏

return value
}
return String(value as number | boolean | bigint)
// TODO(serhalp): Either narrow the type (only number/bigint/boolean reach here at runtime) or keep this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

do you have a linear issue created or is this just a for funzies todo

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I do not subscribe to the philosophy that a todo must have a tracking issue, and I am more than willing to have a debate on this topic on a public stage at a time and place of your choosing. I choose Nathan as my second.

Comment thread src/utils/env/index.ts
*/
export const formatEnvelopeData = ({
context = 'dev',
// TODO(serhalp): Either fix `fetchEnvelopeItems` (it casts a possibly-undefined API response as `EnvelopeItem[]`) or

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same q as above re: funzies

Comment thread src/utils/run-build.ts
}>
export async function runNetlifyBuild({
command,
// TODO(serhalp): Either remove this default (the param is required and every known caller passes it) or keep it if a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants