Skip to content

refactor: replace inlined types with upstream deps - #4239

Merged
pi0 merged 6 commits into
mainfrom
feat/types-from-vendor-deps
May 7, 2026
Merged

pi0 merged 6 commits into
mainfrom
feat/types-from-vendor-deps

Conversation

@RihanArfan

Copy link
Copy Markdown
Member

🔗 Linked issue

#4215

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Move from inlining a copy of types to sourcing them from their dependencies.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@RihanArfan
RihanArfan requested a review from pi0 as a code owner April 29, 2026 14:59
@vercel

vercel Bot commented Apr 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
nitro.build Ready Ready Preview, Comment May 7, 2026 0:23am

Request Review

@coderabbitai

coderabbitai Bot commented Apr 29, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d64b53e5-9d78-49c1-925c-543d23536b63

📥 Commits

Reviewing files that changed from the base of the PR and between d7119ec and 69cbf51.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • package.json
✅ Files skipped from review due to trivial changes (1)
  • package.json

📝 Walkthrough

Walkthrough

Replaces several local TypeScript type definitions with types imported from three newly added devDependencies; removes large Cloudflare Wrangler type modules; adjusts one runtime type assertion and makes a test tolerant of optional OpenAPI info fields.

Changes

Type extraction and replacement

Layer / File(s) Summary
Dependency Additions
package.json
Adds devDependencies: @apphosting/common, @cloudflare/workers-utils, @scalar/openapi-types.
Data Shape / External Types Introduced
src/types/openapi-ts.ts, src/presets/firebase/types.ts, src/presets/cloudflare/types.ts
Replaces local OpenAPI, Firebase output bundle, and Wrangler config type definitions with aliases/types from @scalar/openapi-types (OpenAPIV3_1), @apphosting/common (OutputBundleConfig), and @cloudflare/workers-utils (RawConfig).
Local Type Deletions
src/presets/cloudflare/wrangler/config.ts, src/presets/cloudflare/wrangler/environment.ts, src/presets/cloudflare/wrangler/_utils.ts
Removes extensive local Wrangler config/environment typings and camel-case key utility types.
Runtime Typing Adjustment
src/runtime/internal/routes/openapi.ts
Changes object validation from satisfies OperationObject to as OperationObject when constructing OpenAPI operation objects.
Tests / Wiring
test/presets/nitro-dev.test.ts
Updates test assertions to use optional chaining for spec.info properties (spec.info?.title, spec.info?.description).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

🚥 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
Title check ✅ Passed The title follows conventional commits format with 'refactor:' prefix and clearly describes the main change: replacing inlined types with upstream dependencies.
Description check ✅ Passed The description is related to the changeset, explaining the intent to move from inlining types to sourcing them from their dependencies, which matches the file-level changes throughout.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/types-from-vendor-deps

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.

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

Caution

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

⚠️ Outside diff range comments (1)
package.json (1)

87-103: ⚠️ Potential issue | 🟠 Major

Move these packages to dependencies, not devDependencies.

These modules are no longer build-only: the PR now exposes them through exported types via the public API surface. The export chain flows:

  • @apphosting/common → src/presets/firebase/types.ts → PresetOptions → src/types/config.ts → public ./types export
  • @cloudflare/workers-utils → src/presets/cloudflare/types.ts → PresetOptions → src/types/config.ts → public ./types export
  • @scalar/openapi-types → src/types/openapi-ts.ts → src/types/handler.ts → public ./types export

If they stay in devDependencies, Nitro's emitted .d.ts files will reference packages that app consumers never install, causing downstream Cannot find module ... type-resolution failures.

Suggested package move
   "dependencies": {
+    "@apphosting/common": "^0.0.9",
+    "@cloudflare/workers-utils": "^0.18.0",
+    "@scalar/openapi-types": "^0.7.0",
     "consola": "^3.4.2",
     "crossws": "^0.4.5",
     "db0": "^0.3.4",
@@
   "devDependencies": {
-    "@apphosting/common": "^0.0.9",
     "@azure/functions": "^3.5.1",
@@
-    "@cloudflare/workers-utils": "^0.18.0",
@@
-    "@scalar/openapi-types": "^0.7.0",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 87 - 103, The listed packages (`@apphosting/common`,
`@cloudflare/workers-utils`, `@scalar/openapi-types` and the other shown modules)
are referenced from the public exported typings and must be installed by
consumers, so move them out of devDependencies into dependencies in
package.json; update the package.json sections to place each of the referenced
names (e.g., "@apphosting/common", "@cloudflare/workers-utils",
"@scalar/openapi-types", "@deno/types", "@hiogawa/vite-plugin-fullstack", etc.)
into the top-level "dependencies" object so the emitted .d.ts files resolve for
downstream consumers.
🧹 Nitpick comments (1)
src/runtime/internal/routes/openapi.ts (1)

72-80: Prefer a checked object here instead of as OperationObject.

This cast removes compile-time validation at the point where route meta is turned into the published OpenAPI document. If the upstream Scalar types are stricter now, narrow h.meta?.openAPI or introduce a local helper type instead of asserting the whole object; otherwise invalid operation shapes will silently pass type-checking.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/runtime/internal/routes/openapi.ts` around lines 72 - 80, The code
currently force-casts the merged route entry to OperationObject (in the
PathItemObject creation where "const item" is defined using [method] and
spreading ...openAPI), which silences compile-time validation; replace the
unchecked "as OperationObject" with a safe narrowing: validate or map
h.meta?.openAPI into a locally defined stricter type (or optional partial)
before spreading, e.g., create a helper that picks/validates allowed fields from
openAPI and returns a properly typed OperationObject (or OperationObject |
undefined) and use that helper when building the [method] entry so the compiler
enforces the correct shape instead of an as-cast.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@package.json`:
- Around line 87-103: The listed packages (`@apphosting/common`,
`@cloudflare/workers-utils`, `@scalar/openapi-types` and the other shown modules)
are referenced from the public exported typings and must be installed by
consumers, so move them out of devDependencies into dependencies in
package.json; update the package.json sections to place each of the referenced
names (e.g., "@apphosting/common", "@cloudflare/workers-utils",
"@scalar/openapi-types", "@deno/types", "@hiogawa/vite-plugin-fullstack", etc.)
into the top-level "dependencies" object so the emitted .d.ts files resolve for
downstream consumers.

---

Nitpick comments:
In `@src/runtime/internal/routes/openapi.ts`:
- Around line 72-80: The code currently force-casts the merged route entry to
OperationObject (in the PathItemObject creation where "const item" is defined
using [method] and spreading ...openAPI), which silences compile-time
validation; replace the unchecked "as OperationObject" with a safe narrowing:
validate or map h.meta?.openAPI into a locally defined stricter type (or
optional partial) before spreading, e.g., create a helper that picks/validates
allowed fields from openAPI and returns a properly typed OperationObject (or
OperationObject | undefined) and use that helper when building the [method]
entry so the compiler enforces the correct shape instead of an as-cast.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 35e2f3ae-83be-4dcf-822b-a89f3a7a44d1

📥 Commits

Reviewing files that changed from the base of the PR and between 6016153 and 30d6600.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (9)
  • package.json
  • src/presets/cloudflare/types.ts
  • src/presets/cloudflare/wrangler/_utils.ts
  • src/presets/cloudflare/wrangler/config.ts
  • src/presets/cloudflare/wrangler/environment.ts
  • src/presets/firebase/types.ts
  • src/runtime/internal/routes/openapi.ts
  • src/types/openapi-ts.ts
  • test/presets/nitro-dev.test.ts
💤 Files with no reviewable changes (3)
  • src/presets/cloudflare/wrangler/_utils.ts
  • src/presets/cloudflare/wrangler/config.ts
  • src/presets/cloudflare/wrangler/environment.ts

@pi0

pi0 commented Apr 29, 2026

Copy link
Copy Markdown
Member

Can you please compare dist/ size difference? (are they tree-shaken?)

@socket-security

socket-security Bot commented May 7, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgeist@​1.7.01001001008690
Addedmotion-v@​2.2.110010010093100

View full report

@pi0 pi0 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thnx! i confirmed bundle size is not changes singicifiantly (only ~5 new dts chunks)

for openapi types we likely use standlone types

@socket-security

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
Obfuscated code: npm ioredis is 96.0% likely obfuscated

Confidence: 0.96

Location: Package overview

From: docs/pnpm-lock.yaml → npm/[email protected]

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at [email protected].

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/[email protected]. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@pi0
pi0 merged commit cf5e878 into main May 7, 2026
9 of 11 checks passed
@pi0
pi0 deleted the feat/types-from-vendor-deps branch May 7, 2026 12:36

This branch was successfully deployed

1 active deployment
Preview — 69cbf51a Deployed May 7, 2026 by vercel[bot]
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