fix(openapi): tsconfig erasableSyntaxOnly option not working - #845
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughA new package, Changes
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested labels
Poem
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
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-typedPackage: I've introduced a new internal package,@orpc/json-schema-typed, which acts as a re-export of the externaljson-schema-typedlibrary. This was necessary to address an upstream issue (RemyRylan/json-schema-typed#116) where the original package caused problems when thetsconfigoptionerasableSyntaxOnlywas enabled. - Dependency Migration: The
packages/json-schemaandpackages/openapimodules have been updated to depend on and import types from the newly created@orpc/json-schema-typedpackage, replacing their direct dependency onjson-schema-typed. - Build System Adjustments: Build configurations and
tsconfig.jsonfiles across the monorepo have been adjusted to properly include and resolve the new@orpc/json-schema-typedpackage, 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
-
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. ↩
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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.
| @@ -0,0 +1,76 @@ | |||
| <div align="center"> | |||
| <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" /> | |||
There was a problem hiding this comment.
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").
| <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" /> |
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (6)
packages/openapi/package.json (1)
66-70: Add peerDependency for library consumersSince
@orpc/json-schema-typedis runtime-visible (value imports inschema.ts), expose it as apeerDependenciesentry 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 overrideRepeating
// eslint-disable-next-line no-restricted-importsin every re-export file clutters code. Consider adding a scoped override in.eslintrcfor thepackages/json-schema-typed/srcdirectory 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
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis 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-depsAfter 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 ofjson-schema-typedin node_modules.packages/openapi/tsconfig.json (1)
3-10: Missing composite flag on referenced project
../json-schema-typedmust have"composite": truein its owntsconfig.json; otherwise this reference will break incremental builds.
Please double-check.packages/json-schema/tsconfig.json (1)
7-8: Composite project configuration verifiedThe
packages/json-schema-typed/tsconfig.jsonextendstsconfig.lib.json, which defines both"composite": trueand"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.inlineDependenciesmay be set to:
trueto inline all dependenciesfalseto inline none- an array of dependency names (
string[]) to inline only those packagesPassing
['json-schema-typed']is valid. If, however, json-schema-typed only contains type-only exports (no runtime code), you can safely remove the entirerollupblock—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: truefor project references, this aligns withtsc -b.packages/json-schema/package.json (1)
36-42: No lingering externaljson-schema-typedimports or depsAll 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 entryNo 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
exportstosrcfor workspace dev andpublishConfig.exportstodistfor publish is a solid pattern.
| "scripts": { | ||
| "build": "unbuild", | ||
| "build:watch": "pnpm run build --watch", | ||
| "type:check": "tsc -b" | ||
| }, | ||
| "devDependencies": { | ||
| "json-schema-typed": "^8.0.1" | ||
| } |
There was a problem hiding this comment.
💡 Verification agent
🧩 Analysis chain
Ensure no runtime dependency on json-schema-typed; add sideEffects and consider typesVersions fallback.
- Keeping
json-schema-typedin devDependencies is correct only if the emitted JS does not import it at runtime (type-only re-exports). Ensuresrc/*usesexport typere-exports where applicable. - Add
"sideEffects": falseto aid tree-shaking. - For older TS versions that don’t support
exports.types, considertypesVersionsto 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 -SLength 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.
| "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.
| <div align="center"> | ||
| <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" /> | ||
| </div> |
There was a problem hiding this comment.
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.
| <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" />.
| // eslint-disable-next-line no-restricted-imports | ||
| export * from 'json-schema-typed/draft-2019-09' |
There was a problem hiding this comment.
🛠️ Refactor suggestion
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.
| // eslint-disable-next-line no-restricted-imports | ||
| export * from 'json-schema-typed/draft-2020-12' |
There was a problem hiding this comment.
💡 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.jsonLength 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 useexport type. You must list each type explicitly, as inexport 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:
- 1: https://www.typescriptlang.org/docs/handbook/modules/reference.html
- 2: https://mimo.org/glossary/typescript/module
- 3: https://www.totaltypescript.com/tips/turn-a-module-into-a-type
- 4: https://www.typescriptlang.org/docs/handbook/2/modules.html
- 5: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
- 6: Re-export type from another module microsoft/TypeScript#50122
- 7: https://typescript-eslint.io/blog/consistent-type-imports-and-exports-why-and-how/
- 8: https://community.lambdatest.com/t/what-does-export-type-mean-in-typescript/33969
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.
| // 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.
| // eslint-disable-next-line no-restricted-imports | ||
| export * from 'json-schema-typed' |
There was a problem hiding this comment.
🛠️ Refactor suggestion
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.
| { | ||
| "extends": "../../tsconfig.lib.json", | ||
| "include": ["src"], | ||
| "exclude": [ | ||
| "**/*.test.*", | ||
| "**/*.test-d.ts", | ||
| "**/__tests__/**", | ||
| "**/__mocks__/**", | ||
| "**/__snapshots__/**" | ||
| ] | ||
| } |
There was a problem hiding this comment.
💡 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:
- 1: https://blog.makerx.com.au/running-typescript-directly-with-node-js-no-build-step-required/
- 2: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-8.html
- 3: https://2ality.com/2025/01/tsconfig-json.html
- 4: https://devblogs.microsoft.com/typescript/announcing-typescript-5-8/
- 5: https://devblogs.microsoft.com/typescript/announcing-typescript-5-8-beta/
- 6: Unknown compiler option 'erasableSyntaxOnly' vitejs/vite#20232
- 7: https://www.youtube.com/watch?v=we3tXmqLQBc
- 8: http://npmjs.com/package/eslint-plugin-erasable-syntax-only
- 9: https://www.typescriptlang.org/it/tsconfig/
- 10: https://javascript-conference.com/blog/typescript-5-7-5-8-features-ecmascript-direct-execution/
🏁 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."
fiLength 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.
| { | |
| "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.
| 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' |
There was a problem hiding this comment.
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.
| 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.
More templates
@orpc/arktype
@orpc/client
@orpc/contract
@orpc/experimental-durable-event-iterator
@orpc/hey-api
@orpc/json-schema
@orpc/json-schema-typed
@orpc/nest
@orpc/openapi
@orpc/openapi-client
@orpc/react
@orpc/react-query
@orpc/server
@orpc/shared
@orpc/solid-query
@orpc/standard-server
@orpc/standard-server-aws-lambda
@orpc/standard-server-fetch
@orpc/standard-server-node
@orpc/standard-server-peer
@orpc/svelte-query
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/vue-colada
@orpc/vue-query
@orpc/zod
commit: |
related: RemyRylan/json-schema-typed#116
Summary by CodeRabbit
New Features
@orpc/json-schema-typedpackage, providing re-exports for multiple JSON Schema draft versions under the oRPC namespace.Documentation
@orpc/json-schema-typed, highlighting features, usage, and related packages.Chores
@orpc/json-schema-typedinstead of the externaljson-schema-typed..gitignorefor the new package.