Skip to content

fix(openapi): tsconfig erasableSyntaxOnly option not working - #845

Merged
dinwwwh merged 1 commit into
mainfrom
fix/openapi-json-schema/erasableSyntaxOnly-not-working
Aug 8, 2025
Merged

fix(openapi): tsconfig erasableSyntaxOnly option not working#845
dinwwwh merged 1 commit into
mainfrom
fix/openapi-json-schema/erasableSyntaxOnly-not-working

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Aug 8, 2025

Copy link
Copy Markdown
Member

related: RemyRylan/json-schema-typed#116

Summary by CodeRabbit

  • New Features

    • Introduced the @orpc/json-schema-typed package, providing re-exports for multiple JSON Schema draft versions under the oRPC namespace.
  • Documentation

    • Added a comprehensive README for @orpc/json-schema-typed, highlighting features, usage, and related packages.
  • Chores

    • Updated dependencies in related packages to use @orpc/json-schema-typed instead of the external json-schema-typed.
    • Added build configuration, TypeScript setup, and .gitignore for the new package.
    • Updated TypeScript project references in dependent packages to include the new package.

@vercel

vercel Bot commented Aug 8, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
orpc ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 8, 2025 9:02am

@coderabbitai

coderabbitai Bot commented Aug 8, 2025

Copy link
Copy Markdown

Walkthrough

A new package, @orpc/json-schema-typed, was introduced as a re-export of the upstream json-schema-typed package, with supporting configuration, documentation, and build files. The @orpc/json-schema and @orpc/openapi packages were updated to depend on this new package, and all relevant imports and TypeScript project references were updated accordingly.

Changes

Cohort / File(s) Change Summary
New @orpc/json-schema-typed Package Setup
packages/json-schema-typed/.gitignore, packages/json-schema-typed/README.md, packages/json-schema-typed/build.config.ts, packages/json-schema-typed/package.json, packages/json-schema-typed/tsconfig.json
Added configuration, documentation, build setup, and ignore files for the new @orpc/json-schema-typed package.
@orpc/json-schema-typed Source Files
packages/json-schema-typed/src/index.ts, packages/json-schema-typed/src/draft-07.ts, packages/json-schema-typed/src/draft-2019-09.ts, packages/json-schema-typed/src/draft-2020-12.ts
Added source files that re-export modules from json-schema-typed for main and draft-specific entry points.
@orpc/json-schema Dependency Update
packages/json-schema/package.json
Replaced direct dependency on json-schema-typed with @orpc/json-schema-typed and adjusted workspace dependencies.
@orpc/json-schema Import Path Update
packages/json-schema/src/types.ts
Changed import paths for JSON Schema types to use @orpc/json-schema-typed.
@orpc/json-schema TypeScript Reference Update
packages/json-schema/tsconfig.json
Added TypeScript project reference to ../json-schema-typed.
@orpc/openapi Dependency Update
packages/openapi/package.json
Replaced dependency on json-schema-typed with @orpc/json-schema-typed.
@orpc/openapi Import Path Update
packages/openapi/src/schema.ts
Updated imports to use @orpc/json-schema-typed/draft-2020-12.
@orpc/openapi TypeScript Reference Update
packages/openapi/tsconfig.json
Added TypeScript project reference to ../json-schema-typed.

Sequence Diagram(s)

sequenceDiagram
    participant Consumer as Consumer Package (json-schema, openapi)
    participant ORPCJST as @orpc/json-schema-typed
    participant JST as json-schema-typed (upstream)

    Consumer->>ORPCJST: import { ... } from '@orpc/json-schema-typed'
    ORPCJST->>JST: re-export all from 'json-schema-typed'
    Note right of Consumer: Consumer transparently uses upstream types via ORPC package
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

size:XL

Poem

A new schema hops into view,
With re-exports crisp and tidy too!
Imports now all point one way,
Through orpc fields they play.
Type-safety blooms, dependencies align—
A rabbit’s work, both neat and fine!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/openapi-json-schema/erasableSyntaxOnly-not-working

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@gemini-code-assist gemini-code-assist 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.

Summary of Changes

Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've implemented a fix for an issue where the tsconfig option erasableSyntaxOnly was causing problems with the json-schema-typed dependency. My solution involves creating a new internal package, @orpc/json-schema-typed, which simply re-exports the contents of the problematic external library. This allows us to control the build process and type resolution for json-schema-typed within our monorepo, effectively working around the upstream issue without modifying the original library. This change ensures that our OpenAPI-related functionalities continue to work correctly with the specified tsconfig options.

Highlights

  • New @orpc/json-schema-typed Package: I've introduced a new internal package, @orpc/json-schema-typed, which acts as a re-export of the external json-schema-typed library. This was necessary to address an upstream issue (RemyRylan/json-schema-typed#116) where the original package caused problems when the tsconfig option erasableSyntaxOnly was enabled.
  • Dependency Migration: The packages/json-schema and packages/openapi modules have been updated to depend on and import types from the newly created @orpc/json-schema-typed package, replacing their direct dependency on json-schema-typed.
  • Build System Adjustments: Build configurations and tsconfig.json files across the monorepo have been adjusted to properly include and resolve the new @orpc/json-schema-typed package, ensuring smooth compilation and type checking.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Aug 8, 2025
@codecov

codecov Bot commented Aug 8, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.50000% with 3 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
packages/json-schema-typed/src/draft-07.ts 50.00% 1 Missing ⚠️
packages/json-schema-typed/src/draft-2019-09.ts 50.00% 1 Missing ⚠️
packages/json-schema-typed/src/index.ts 50.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces a new package, @orpc/json-schema-typed, to work around an upstream issue with json-schema-typed and TypeScript's erasableSyntaxOnly option. The new package re-exports the types from the original package and is now used throughout the monorepo. The approach is sound and the implementation is correct. I've added a few minor suggestions to improve the new package's README and .gitignore file for better correctness and adherence to common conventions.

Comment thread packages/json-schema-typed/.gitignore
@@ -0,0 +1,76 @@
<div align="center">
<image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />

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.

medium

The <image> tag is not a standard HTML tag. For better compatibility and correctness, you should use the <img> tag instead. Also, HTML attribute values should ideally be quoted (e.g., width="280").

Suggested change
<image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
<img align="center" src="https://orpc.unnoq.com/logo.webp" width="280" alt="oRPC logo" />

Comment thread packages/json-schema-typed/README.md

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

Actionable comments posted: 7

🧹 Nitpick comments (6)
packages/openapi/package.json (1)

66-70: Add peerDependency for library consumers

Since @orpc/json-schema-typed is runtime-visible (value imports in schema.ts), expose it as a peerDependencies entry to prevent duplicate installs when this package is consumed outside the monorepo.

packages/json-schema-typed/src/draft-07.ts (1)

1-2: Prefer project-wide ESLint override

Repeating // eslint-disable-next-line no-restricted-imports in every re-export file clutters code. Consider adding a scoped override in .eslintrc for the packages/json-schema-typed/src directory instead.

packages/json-schema-typed/.gitignore (1)

1-26: Ignore patterns are sensible for a leaf TS package.

Covers common outputs and temp files. Note: .* also ignores dotfiles (e.g., .npmrc, .eslintrc.cjs) inside this package. If you plan to add any such config files locally, whitelist them similarly to .gitignore.

packages/json-schema-typed/README.md (3)

5-5: Remove empty H1 for cleaner semantics.

An empty <h1></h1> is unnecessary and may confuse screen readers.

-<h1></h1>
+

68-71: Add alt text to sponsors image (MD045).

Improve accessibility by adding descriptive alt text.

-    <img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
+    <img alt="oRPC Sponsors" src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>

49-61: Optional: Rephrase repeated list item intros flagged by linter (style).

The repeated - [@orpc/...]: pattern is fine for a package list, but if you want to appease the style checker, consider grouping or varying phrasing. No functional impact.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7eaeef7 and 00d6f7f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (15)
  • packages/json-schema-typed/.gitignore (1 hunks)
  • packages/json-schema-typed/README.md (1 hunks)
  • packages/json-schema-typed/build.config.ts (1 hunks)
  • packages/json-schema-typed/package.json (1 hunks)
  • packages/json-schema-typed/src/draft-07.ts (1 hunks)
  • packages/json-schema-typed/src/draft-2019-09.ts (1 hunks)
  • packages/json-schema-typed/src/draft-2020-12.ts (1 hunks)
  • packages/json-schema-typed/src/index.ts (1 hunks)
  • packages/json-schema-typed/tsconfig.json (1 hunks)
  • packages/json-schema/package.json (1 hunks)
  • packages/json-schema/src/types.ts (1 hunks)
  • packages/json-schema/tsconfig.json (1 hunks)
  • packages/openapi/package.json (1 hunks)
  • packages/openapi/src/schema.ts (1 hunks)
  • packages/openapi/tsconfig.json (1 hunks)
🧰 Additional context used
🪛 LanguageTool
packages/json-schema-typed/README.md

[style] ~51-~51: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... your API or implement API contract. - [@orpc/client](https://www.npmjs.com/package/@...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~52-~52: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... API on the client with type-safety. - [@orpc/openapi](https://www.npmjs.com/package/...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~53-~53: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...I specs and handle OpenAPI requests. - [@orpc/nest](https://www.npmjs.com/package/@or...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~54-~54: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ... with NestJS. - [@orpc/react](https://www.npmjs.com/package/@o...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~55-~55: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...with React and React Server Actions. - [@orpc/tanstack-query](https://www.npmjs.com/p...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~56-~56: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...stack.com/query/latest) integration. - [@orpc/vue-colada](https://www.npmjs.com/packa...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~57-~57: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...ada](https://pinia-colada.esm.dev/). - [@orpc/hey-api](https://www.npmjs.com/package/...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~58-~58: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...I](https://heyapi.dev/) integration. - [@orpc/zod](https://www.npmjs.com/package/@orp...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~59-~59: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...tps://zod.dev/) doesn't support yet. - [@orpc/valibot](https://www.npmjs.com/package/...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)


[style] ~60-~60: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...rom Valibot. - [@orpc/arktype](https://www.npmjs.com/package/...

(ENGLISH_WORD_REPEAT_BEGINNING_RULE)

🪛 markdownlint-cli2 (0.17.2)
packages/json-schema-typed/README.md

70-70: Images should have alternate text (alt text)

(MD045, no-alt-text)

⏰ 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: publish-commit
  • GitHub Check: lint
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (7)
packages/json-schema/src/types.ts (1)

2-4: Confirm workspace linking & peer-deps

After switching to @orpc/json-schema-typed/*, ensure this package declares a workspace/dev-dependency on @orpc/json-schema-typed (and removes the old one) so that consumers don’t end up with two copies of json-schema-typed in node_modules.

packages/openapi/tsconfig.json (1)

3-10: Missing composite flag on referenced project

../json-schema-typed must have "composite": true in its own tsconfig.json; otherwise this reference will break incremental builds.
Please double-check.

packages/json-schema/tsconfig.json (1)

7-8: Composite project configuration verified

The packages/json-schema-typed/tsconfig.json extends tsconfig.lib.json, which defines both "composite": true and "declaration": true. No further changes are needed for the project reference to build successfully.

packages/json-schema-typed/build.config.ts (1)

4-6: inlineDependencies supports both boolean and string[]

According to Rollup’s documentation (and unbuild’s mapping of its options), rollup.inlineDependencies may be set to:

  • true to inline all dependencies
  • false to inline none
  • an array of dependency names (string[]) to inline only those packages

Passing ['json-schema-typed'] is valid. If, however, json-schema-typed only contains type-only exports (no runtime code), you can safely remove the entire rollup block—but there’s no type error in using the array form.

Likely an incorrect or invalid review comment.

packages/json-schema-typed/tsconfig.json (1)

1-11: Minimal tsconfig looks fine for a leaf package.

Includes src-only and excludes tests/snapshots. Assuming the base tsconfig sets composite: true for project references, this aligns with tsc -b.

packages/json-schema/package.json (1)

36-42: No lingering external json-schema-typed imports or deps

All references are confined to the wrapper package as intended:

  • packages/json-schema-typed/src/index.ts: single export * from 'json-schema-typed' re-export
  • packages/json-schema-typed/package.json: "json-schema-typed": "^8.0.1" dependency entry

No further action required—approving these changes.

packages/json-schema-typed/package.json (1)

16-45: Exports mapping and publishConfig look correct for dist ESM + DTS.

Top-level exports to src for workspace dev and publishConfig.exports to dist for publish is a solid pattern.

Comment on lines +49 to +56
"scripts": {
"build": "unbuild",
"build:watch": "pnpm run build --watch",
"type:check": "tsc -b"
},
"devDependencies": {
"json-schema-typed": "^8.0.1"
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Ensure no runtime dependency on json-schema-typed; add sideEffects and consider typesVersions fallback.

  • Keeping json-schema-typed in devDependencies is correct only if the emitted JS does not import it at runtime (type-only re-exports). Ensure src/* uses export type re-exports where applicable.
  • Add "sideEffects": false to aid tree-shaking.
  • For older TS versions that don’t support exports.types, consider typesVersions to map subpaths to DTS as a fallback.

Proposed updates:

   "scripts": {
     "build": "unbuild",
     "build:watch": "pnpm run build --watch",
     "type:check": "tsc -b"
   },
+  "sideEffects": false,
   "devDependencies": {
     "json-schema-typed": "^8.0.1"
   }

And optionally add for broader TS compatibility:

"typesVersions": {
  "*": {
    "": ["dist/index.d.mts"],
    "draft-07": ["dist/draft-07.d.mts"],
    "draft-2019-09": ["dist/draft-2019-09.d.mts"],
    "draft-2020-12": ["dist/draft-2020-12.d.mts"]
  }
}

Confirm your re-exports are type-only (so JS has no runtime import):

Expected: no matches. If matches exist, convert to export type.


🏁 Script executed:

#!/bin/bash
# Inspect re-exports in the wrapper source: prefer `export type { ... } from 'json-schema-typed'`
rg -n "export\\s+(?!type).*from\\s+['\"]json-schema-typed['\"]" packages/json-schema-typed/src -S

Length of output: 365


🏁 Script executed:

#!/bin/bash
# List any non–type-only re-exports from json-schema-typed in the wrapper source
rg -n "export.*from\s+['\"]json-schema-typed['\"]" packages/json-schema-typed/src -S | grep -v "export type"

Length of output: 190


Refactor runtime export to type-only; add sideEffects & typesVersions

Your wrapper is currently doing a full re-export, which pulls in a runtime import of your devDependency. To avoid shipping a runtime dependency on json-schema-typed, please:

• In packages/json-schema-typed/src/index.ts, replace the runtime export:

- export * from 'json-schema-typed'
+ import type * as JSONSchemaTyped from 'json-schema-typed'
+ export type { JSONSchemaTyped }

(Or, if you’re on TS 4.5+, you can use export type * as JSONSchemaTyped from 'json-schema-typed';.)

• In packages/json-schema-typed/package.json, add:

  "scripts": {
    "build": "unbuild",
    "build:watch": "pnpm run build --watch",
    "type:check": "tsc -b"
  },
+ "sideEffects": false,
  "devDependencies": {
    "json-schema-typed": "^8.0.1"
  },
+ "typesVersions": {
+   "*": {
+     "": ["dist/index.d.mts"],
+     "draft-07": ["dist/draft-07.d.mts"],
+     "draft-2019-09": ["dist/draft-2019-09.d.mts"],
+     "draft-2020-12": ["dist/draft-2020-12.d.mts"]
+   }
+ }

This ensures no runtime import of your devDependency, enables tree-shaking, and provides a fallback for older TS versions.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"scripts": {
"build": "unbuild",
"build:watch": "pnpm run build --watch",
"type:check": "tsc -b"
},
"devDependencies": {
"json-schema-typed": "^8.0.1"
}
"scripts": {
"build": "unbuild",
"build:watch": "pnpm run build --watch",
"type:check": "tsc -b"
},
"sideEffects": false,
"devDependencies": {
"json-schema-typed": "^8.0.1"
},
"typesVersions": {
"*": {
"": ["dist/index.d.mts"],
"draft-07": ["dist/draft-07.d.mts"],
"draft-2019-09": ["dist/draft-2019-09.d.mts"],
"draft-2020-12": ["dist/draft-2020-12.d.mts"]
}
}
🤖 Prompt for AI Agents
In packages/json-schema-typed/package.json around lines 49 to 56, you need to
prevent runtime imports of the devDependency by changing your wrapper export to
a type-only export in packages/json-schema-typed/src/index.ts, using either
`export type * as JSONSchemaTyped from 'json-schema-typed';` if on TS 4.5+, or
an equivalent type-only export. Additionally, update package.json to include the
"sideEffects": false field and add a "typesVersions" mapping to support older
TypeScript versions, ensuring no runtime dependency is shipped and enabling
proper tree-shaking.

Comment on lines +1 to +3
<div align="center">
<image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
</div>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix invalid HTML tag: use instead of .

<image> is not a valid HTML element and won’t render on GitHub. Replace it with <img>.

Apply:

-  <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
+  <img align="center" src="https://orpc.unnoq.com/logo.webp" width="280" alt="oRPC logo" />
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<div align="center">
<image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
</div>
<div align="center">
<img align="center" src="https://orpc.unnoq.com/logo.webp" width="280" alt="oRPC logo" />
</div>
🤖 Prompt for AI Agents
In packages/json-schema-typed/README.md at lines 1 to 3, replace the invalid
HTML tag <image> with the correct <img> tag to ensure proper rendering on
GitHub. Change <image align="center" src="https://orpc.unnoq.com/logo.webp"
width=280 alt="oRPC logo" /> to <img align="center"
src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />.

Comment on lines +1 to +2
// eslint-disable-next-line no-restricted-imports
export * from 'json-schema-typed/draft-2019-09'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Same here: re-export types only to prevent runtime import of a types-only package

Align with the goal of erasableSyntaxOnly and avoid emitting export * from ... in JS.

-// eslint-disable-next-line no-restricted-imports
-export * from 'json-schema-typed/draft-2019-09'
+// eslint-disable-next-line no-restricted-imports
+export type * from 'json-schema-typed/draft-2019-09'

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In packages/json-schema-typed/src/draft-2019-09.ts at lines 1 to 2, the current
code uses a runtime export statement that imports the entire module, which can
cause unwanted runtime imports of a types-only package. To fix this, change the
export to a types-only re-export by using the `export type` syntax to re-export
only types, preventing any runtime import and aligning with erasableSyntaxOnly
goals.

Comment on lines +1 to +2
// eslint-disable-next-line no-restricted-imports
export * from 'json-schema-typed/draft-2020-12'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Use type-only re-export to avoid runtime re-export and make erasableSyntaxOnly effective

export * from 'json-schema-typed/...' emits a runtime re-export, which defeats the purpose of erasableSyntaxOnly and can break at runtime since json-schema-typed is types-only. Re-export types only.

-// eslint-disable-next-line no-restricted-imports
-export * from 'json-schema-typed/draft-2020-12'
+// Re-export types only to ensure zero runtime emission.
+// eslint-disable-next-line no-restricted-imports
+export type * from 'json-schema-typed/draft-2020-12'

If your TypeScript version doesn’t support export type *, fall back to named type re-exports (less ideal) or keep a .d.ts shim file for re-exports.


🏁 Script executed:

#!/bin/bash
# Verify TS version supports `export type *` and that the repo pins >=5.5
rg -n --hidden --glob '!**/node_modules/**' '"typescript":\s*".*"' -S package.json

Length of output: 115


🌐 Web query:

Does TypeScript support `export type * from "module"` and from which version?

💡 Result:

TypeScript does not support the syntax export type * from "module" as of August 2025. Instead, only named type re-exports are allowed using export type { ... } from "module", or, since TypeScript 4.5, inline with export { type ... } from "module"[6][7].

Details:

  • Attempting export type * from "module" will result in a compiler error: Only named exports may use export type. You must list each type explicitly, as in export type { Foo, Bar } from "module", rather than using the * wildcard.[6]
  • This is a known limitation in TypeScript: The GitHub discussion in [6] explains that export type * from "module" is not currently supported and suggests using named re-exports.
  • Why isn't it supported? The limitation is due to how TypeScript elides type-only exports from output JavaScript and the differences from runtime exports. Implementing wildcard type-only exports would require additional specification and compiler changes.[6][7]
  • Current alternatives: To re-export all types, you must manually list them, e.g.:
    export type { TypeA, TypeB } from "./module";
    // or with inline type-only exports (since TS 4.5)
    export { type TypeA, type TypeB } from "./module";
  • Type-only export * from "module" (i.e., re-exporting all values and types) is allowed, but this includes runtime exports and does not produce a type-only re-export.[6][7]

Summary table:

Syntax Supported? Version/support details
export type * from "module" No Not supported in any TS as of Aug 2025[6]
export type { Foo } from ... Yes Since TypeScript 3.8[7]
export { type Foo } from ... Yes Since TypeScript 4.5[7]

TypeScript documentation confirms only named type re-exports are supported; wildcard type-only re-exports (export type *) are not currently valid[1][7].

Citations:


Use named type‐only re-exports instead of a wildcard
TypeScript does not support export type * from "…". To avoid emitting a runtime export (which will break when the module only contains types), list the exported types explicitly:

• File: packages/json-schema-typed/src/draft-2020-12.ts
• Lines: 1–2

- // eslint-disable-next-line no-restricted-imports
- export * from 'json-schema-typed/draft-2020-12'
+ // Re-export types only to ensure zero runtime emission.
+ // eslint-disable-next-line no-restricted-imports
+ export type {
+   /* replace with actual names exported by draft-2020-12, for example: */
+   JSONSchema,
+   SchemaOptions,
+   ValidateFunction,
+   /* … */
+ } from 'json-schema-typed/draft-2020-12'

If maintaining the full list of types by hand is too cumbersome, consider a .d.ts shim that re-exports everything in one place.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// eslint-disable-next-line no-restricted-imports
export * from 'json-schema-typed/draft-2020-12'
// Re-export types only to ensure zero runtime emission.
// eslint-disable-next-line no-restricted-imports
export type {
/* replace with actual names exported by draft-2020-12, for example: */
JSONSchema,
SchemaOptions,
ValidateFunction,
/* … */
} from 'json-schema-typed/draft-2020-12'
🤖 Prompt for AI Agents
In packages/json-schema-typed/src/draft-2020-12.ts at lines 1 to 2, replace the
wildcard export with named type-only exports by explicitly listing each type to
avoid emitting runtime exports. If the list of types is large, create a .d.ts
shim file that re-exports all types in one place and import from there to keep
the code maintainable.

Comment on lines +1 to +2
// eslint-disable-next-line no-restricted-imports
export * from 'json-schema-typed'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

⚠️ Potential issue

Type-only re-export to ensure zero JS emission and fix erasableSyntaxOnly behavior

Avoid emitting export * from 'json-schema-typed' at runtime from a types-only package.

-// eslint-disable-next-line no-restricted-imports
-export * from 'json-schema-typed'
+// Re-export types only.
+// eslint-disable-next-line no-restricted-imports
+export type * from 'json-schema-typed'

If export type * isn’t available in your TS version, consider using a .d.ts entrypoint that re-exports from json-schema-typed so it never emits JS.

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In packages/json-schema-typed/src/index.ts at lines 1 to 2, the current export
statement emits JavaScript code at runtime, which is undesirable for a
types-only package. Replace the export with a type-only re-export using `export
type { ... }` syntax if supported by your TypeScript version, or alternatively
create a `.d.ts` declaration file that re-exports the types from
'json-schema-typed' to ensure no JavaScript is emitted.

Comment on lines +1 to +11
{
"extends": "../../tsconfig.lib.json",
"include": ["src"],
"exclude": [
"**/*.test.*",
"**/*.test-d.ts",
"**/__tests__/**",
"**/__mocks__/**",
"**/__snapshots__/**"
]
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Make type-only elision explicit to avoid runtime imports (ties to erasableSyntaxOnly).

If the goal is to ensure re-exports are erased at emit time (no runtime import of json-schema-typed), explicitly enabling verbatimModuleSyntax and preserving value imports improves consistency across toolchains. If these are already in ../../tsconfig.lib.json, ignore this.

Apply if not set in the base config:

 {
   "extends": "../../tsconfig.lib.json",
+  "compilerOptions": {
+    // Ensure type-only re-exports are preserved as type and safely erased in JS output.
+    "verbatimModuleSyntax": true,
+    "preserveValueImports": true
+  },
   "include": ["src"],
   "exclude": [
     "**/*.test.*",
     "**/*.test-d.ts",
     "**/__tests__/**",
     "**/__mocks__/**",
     "**/__snapshots__/**"
   ]
 }

To confirm the intended behavior and TS support for your toolchain, please check the compiler option details:


🌐 Web query:

What does the TypeScript compiler option `erasableSyntaxOnly` do and from which TS version is it available?

💡 Result:

The TypeScript compiler option erasableSyntaxOnly ensures that your TypeScript code uses only constructs that can be safely erased—i.e., stripped of type information—without changing its runtime behavior. This is particularly important for environments like Node.js that support running TypeScript files directly by stripping types at runtime; only language features that are purely type-level or whose syntax can be trivially removed from the emitted JavaScript are allowed[1][2][4][10].

When enabled, TypeScript will error on constructs that have runtime semantics and cannot be erased by simple type stripping. This includes, but is not limited to:

  • Enums
  • Namespaces and modules with runtime code
  • Parameter properties in classes (e.g., constructor(public x: number))
  • Non-ECMAScript import/export assignments (e.g., import =, export =)[1][2][4][5][8]

Example of disallowed syntax under erasableSyntaxOnly:

// ❌ Not allowed
enum Direction { Up, Down, Left, Right; }

namespace Container { export const value = 42; }

import Bar = Container.Bar;

class Person { constructor(private name: string, public age: number) {} }

Availability:
The erasableSyntaxOnly option is available starting in TypeScript 5.8; attempting to use it with earlier versions will result in an "Unknown compiler option" error[1][4][5][6][10].

For best results, it is recommended to pair erasableSyntaxOnly with verbatimModuleSyntax when targeting direct execution environments or type-stripping workflows[2][3][4].

Summary Table:

Compiler Option Purpose Available Since
erasableSyntaxOnly Restrict to TypeScript syntax that can be fully erased with no runtime semantics. TypeScript 5.8

Citations:


🏁 Script executed:

#!/bin/bash
# Verify whether the base tsconfig already opts into explicit type-only elision
echo "🔍 Checking tsconfig.lib.json for verbatimModuleSyntax and preserveValueImports…"

if [ -f tsconfig.lib.json ]; then
  rg -n '"verbatimModuleSyntax"' tsconfig.lib.json || echo "❌ verbatimModuleSyntax not found"
  rg -n '"preserveValueImports"' tsconfig.lib.json || echo "❌ preserveValueImports not found"
else
  echo "⚠️ tsconfig.lib.json not found at repo root."
fi

Length of output: 453


Enable explicit type-only elision in your package tsconfig

Your base config (../../tsconfig.lib.json) does not yet enable verbatimModuleSyntax or preserveValueImports, which paired with erasableSyntaxOnly (TS 5.8+) ensures that all type-only exports are fully erased at emit time and no unexpected runtime imports occur. Please update:

• File: packages/json-schema-typed/tsconfig.json

Apply this diff:

 {
   "extends": "../../tsconfig.lib.json",
+  "compilerOptions": {
+    // Ensure type-only exports are emitted as types only and safely erased in JS
+    "verbatimModuleSyntax": true,
+    "preserveValueImports": true
+  },
   "include": ["src"],
   "exclude": [
     "**/*.test.*",
     "**/*.test-d.ts",
     "**/__tests__/**",
     "**/__mocks__/**",
     "**/__snapshots__/**"
   ]
 }

Make sure your project uses TypeScript >= 5.8 to leverage erasableSyntaxOnly workflows.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
"extends": "../../tsconfig.lib.json",
"include": ["src"],
"exclude": [
"**/*.test.*",
"**/*.test-d.ts",
"**/__tests__/**",
"**/__mocks__/**",
"**/__snapshots__/**"
]
}
{
"extends": "../../tsconfig.lib.json",
"compilerOptions": {
// Ensure type-only exports are emitted as types only and safely erased in JS
"verbatimModuleSyntax": true,
"preserveValueImports": true
},
"include": ["src"],
"exclude": [
"**/*.test.*",
"**/*.test-d.ts",
"**/__tests__/**",
"**/__mocks__/**",
"**/__snapshots__/**"
]
}
🤖 Prompt for AI Agents
In packages/json-schema-typed/tsconfig.json lines 1 to 11, update the
compilerOptions to enable explicit type-only elision by adding
"verbatimModuleSyntax": true and "preserveValueImports": true alongside
"erasableSyntaxOnly" if applicable. This requires ensuring TypeScript version is
5.8 or higher. Modify the tsconfig to include these options so that type-only
exports are fully erased at emit time, preventing unexpected runtime imports.

Comment on lines +2 to +3
import type { JSONSchema, keywords } from '@orpc/json-schema-typed/draft-2020-12'
import { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@orpc/json-schema-typed/draft-2020-12'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

keywords wrongly imported with import type

typeof keywords relies on the value symbol, but import type erases it.
Compilation will fail with “only refers to a type, but is being used as a value”.

-import type { JSONSchema, keywords } from '@orpc/json-schema-typed/draft-2020-12'
+import { keywords } from '@orpc/json-schema-typed/draft-2020-12'
+import type { JSONSchema } from '@orpc/json-schema-typed/draft-2020-12'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import type { JSONSchema, keywords } from '@orpc/json-schema-typed/draft-2020-12'
import { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@orpc/json-schema-typed/draft-2020-12'
import { keywords } from '@orpc/json-schema-typed/draft-2020-12'
import type { JSONSchema } from '@orpc/json-schema-typed/draft-2020-12'
import { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@orpc/json-schema-typed/draft-2020-12'
🤖 Prompt for AI Agents
In packages/openapi/src/schema.ts at lines 2 to 3, the `keywords` import is
incorrectly imported using `import type`, which removes the value symbol needed
for `typeof keywords`. Change the import of `keywords` from `import type` to a
regular import so that both the type and value are available, preventing
compilation errors.

@pkg-pr-new

pkg-pr-new Bot commented Aug 8, 2025

Copy link
Copy Markdown
More templates

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@845

@orpc/client

npm i https://pkg.pr.new/@orpc/client@845

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@845

@orpc/experimental-durable-event-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-event-iterator@845

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@845

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@845

@orpc/json-schema-typed

npm i https://pkg.pr.new/@orpc/json-schema-typed@845

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@845

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@845

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@845

@orpc/react

npm i https://pkg.pr.new/@orpc/react@845

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@845

@orpc/server

npm i https://pkg.pr.new/@orpc/server@845

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@845

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@845

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@845

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@845

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@845

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@845

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@845

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@845

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@845

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@845

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@845

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@845

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@845

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@845

commit: 00d6f7f

@dinwwwh
dinwwwh merged commit 18a9741 into main Aug 8, 2025
12 of 14 checks passed
@dinwwwh
dinwwwh deleted the fix/openapi-json-schema/erasableSyntaxOnly-not-working branch June 22, 2026 01:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant