Skip to content

build: upgrade to native typescript v7 🚀 - #8357

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

build: upgrade to native typescript v7 🚀#8357
serhalp wants to merge 6 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

Summary by CodeRabbit

  • Bug Fixes

    • Improved API command handling for invalid JSON input, including clearer error messages and previews of rejected data.
    • Added more helpful guidance when required API path variables are missing.
    • Improved workspace and site selection consistency across commands.
    • Preserved reliable environment context handling and temporary file cleanup.
  • Chores

    • Updated the CLI version and TypeScript build tooling.
    • Improved build configuration and handling of generated build artifacts.

Walkthrough

The PR aligns build and typecheck scripts with the native TypeScript compiler, updates TypeScript dependencies, and adjusts compiler configuration. Source changes refine API validation, site state handling, 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

Possibly related issues

  • netlify/framework-adapters#14 — Updates overlapping TypeScript and TypeScript ESLint dependencies.

Possibly related PRs

  • netlify/cli#8333 — Implements related API --data parsing and missing path-variable error handling.

Suggested reviewers: aitchiss

🚥 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 TypeScript tooling to native v7.
Description check ✅ Passed The description matches the changeset and explains the TypeScript v7 upgrade and the typescript-eslint compatibility workaround.
✨ Finishing Touches 💡 1
📝 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

github-actions Bot commented Jul 24, 2026

Copy link
Copy Markdown

📊 Benchmark results

Comparing with 13397d3

  • Dependency count: 1,166 ⬆️ 0.60% increase vs. 13397d3
  • Package size: 454 MB ⬆️ 10.99% increase vs. 13397d3
  • 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

@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 Outdated
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 Outdated
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.

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.

(and I don't want to risk behavioural changes in this PR)

Comment thread src/utils/env/index.ts Outdated
*/
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 Outdated
}>
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

@serhalp
serhalp requested a review from sarahetter July 30, 2026 15:24

@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: ad2fc78180

ℹ️ 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 tsconfig.build.json
"sourceMap": true
"rootDir": "src",
"sourceMap": true,
"tsBuildInfoFile": "./tsconfig.build.tsbuildinfo"

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 Remove the build cache when cleaning output

Because this moves the incremental build-info file outside dist/, the existing npm run clean script—which only removes dist/—now leaves the cache intact. After a successful build, running npm run clean && npm run build causes the compiler to regard unchanged inputs as already emitted, so it can recreate no dist files and leave the CLI unbuildable. Keep the cache under dist or delete tsconfig.build.tsbuildinfo in the clean script.

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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/commands/api/api.ts (2)

41-43: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Fix the malformed invalid-method error.

The message currently renders two closing quotes, for example "getSite"" is not a valid api method.

Proposed fix
-      `"${apiMethodName}"" is not a valid api method. Run "netlify api --list" to see available methods`,
+      `"${apiMethodName}" is not a valid api method. Run "netlify api --list" to see available methods`,
🤖 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/commands/api/api.ts` around lines 41 - 43, The invalid-method error
message in the api method validation path has an extra closing quote after
apiMethodName. Update the logAndThrowError message to render exactly one pair of
quotes around apiMethodName while preserving the existing text and behavior.

52-58: 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Do not send raw --data previews to telemetry.

The preview is interpolated into the error passed to logAndThrowError, which reports that error through reportError. Malformed input can therefore expose secrets or PII. Redact or remove the preview, and update the corresponding expectations in tests/unit/commands/api/api.test.ts Lines 35-48.

🤖 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/commands/api/api.ts` around lines 52 - 58, Remove or redact the
user-supplied preview from the invalid JSON error constructed in the API command
before it reaches logAndThrowError and reportError. Keep the validation guidance
intact without exposing raw --data content, and update the corresponding
expectations in the API command unit tests.
🤖 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 `@src/commands/api/api.ts`:
- Around line 47-65: Update the --data handling in the API command to
distinguish an omitted value from an empty string, so explicitly provided empty
input is rejected rather than replaced with {}. After JSON.parse in the
options.data branch, validate that payload is a non-null object and not an
array; route invalid strings and parsed non-object values through
logAndThrowError, and invoke the API only with a valid object or the existing
default for omitted data.

---

Outside diff comments:
In `@src/commands/api/api.ts`:
- Around line 41-43: The invalid-method error message in the api method
validation path has an extra closing quote after apiMethodName. Update the
logAndThrowError message to render exactly one pair of quotes around
apiMethodName while preserving the existing text and behavior.
- Around line 52-58: Remove or redact the user-supplied preview from the invalid
JSON error constructed in the API command before it reaches logAndThrowError and
reportError. Keep the validation guidance intact without exposing raw --data
content, and update the corresponding expectations in the API command unit
tests.
🪄 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: b70b4150-217f-4ee5-ad9e-dddb7f5d97ba

📥 Commits

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

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (8)
  • 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/utils/env/index.ts
  • src/utils/run-build.ts
  • tests/unit/commands/api/api.test.ts
🔗 Linked repositories identified

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

  • netlify/blueprints (manual)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/utils/env/index.ts
  • src/commands/database/util/psql-formatter.ts

Comment thread src/commands/api/api.ts
Comment on lines 47 to 65
@@ -59,7 +64,7 @@ Note: key=value pairs are not accepted; use JSON syntax instead.`,
payload = {}
}

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Reject empty and non-object --data values.

if (options.data) treats --data "" as absent and sends {}. JSON.parse also accepts null, arrays, and primitives, although the error explicitly says this flag expects an object. Validate presence explicitly and require a non-null, non-array object before invoking the API.

🤖 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/commands/api/api.ts` around lines 47 - 65, Update the --data handling in
the API command to distinguish an omitted value from an empty string, so
explicitly provided empty input is rejected rather than replaced with {}. After
JSON.parse in the options.data branch, validate that payload is a non-null
object and not an array; route invalid strings and parsed non-object values
through logAndThrowError, and invoke the API only with a valid object or the
existing default for omitted data.

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