-
-
Notifications
You must be signed in to change notification settings - Fork 159
fix(openapi): tsconfig erasableSyntaxOnly option not working #845
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # Hidden folders and files | ||
| .* | ||
| !.gitignore | ||
| !.*.example | ||
|
|
||
| # Common generated folders | ||
| logs/ | ||
| node_modules/ | ||
| out/ | ||
| dist/ | ||
| dist-ssr/ | ||
| build/ | ||
| coverage/ | ||
| temp/ | ||
|
|
||
| # Common generated files | ||
| *.log | ||
| *.log.* | ||
| *.tsbuildinfo | ||
| *.vitest-temp.json | ||
| vite.config.ts.timestamp-* | ||
| vitest.config.ts.timestamp-* | ||
|
|
||
| # Common manual ignore files | ||
| *.local | ||
| *.pem | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,76 @@ | ||||||||||||||
| <div align="center"> | ||||||||||||||
| <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" /> | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||
| </div> | ||||||||||||||
|
Comment on lines
+1
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix invalid HTML tag: use
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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| <h1></h1> | ||||||||||||||
|
dinwwwh marked this conversation as resolved.
|
||||||||||||||
|
|
||||||||||||||
| <div align="center"> | ||||||||||||||
| <a href="https://codecov.io/gh/unnoq/orpc"> | ||||||||||||||
| <img alt="codecov" src="https://codecov.io/gh/unnoq/orpc/branch/main/graph/badge.svg"> | ||||||||||||||
| </a> | ||||||||||||||
| <a href="https://www.npmjs.com/package/@orpc/json-schema-typed"> | ||||||||||||||
| <img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fjson-schema-typed?logo=npm" /> | ||||||||||||||
| </a> | ||||||||||||||
| <a href="https://github.com/unnoq/orpc/blob/main/LICENSE"> | ||||||||||||||
| <img alt="MIT License" src="https://img.shields.io/github/license/unnoq/orpc?logo=open-source-initiative" /> | ||||||||||||||
| </a> | ||||||||||||||
| <a href="https://discord.gg/TXEbwRBvQn"> | ||||||||||||||
| <img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" /> | ||||||||||||||
| </a> | ||||||||||||||
| </div> | ||||||||||||||
|
|
||||||||||||||
| <h3 align="center">Typesafe APIs Made Simple 🪄</h3> | ||||||||||||||
|
|
||||||||||||||
| **oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards | ||||||||||||||
|
|
||||||||||||||
| --- | ||||||||||||||
|
|
||||||||||||||
| ## Highlights | ||||||||||||||
|
|
||||||||||||||
| - **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server. | ||||||||||||||
| - **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard. | ||||||||||||||
| - **📝 Contract-First Development**: Optionally define your API contract before implementation. | ||||||||||||||
| - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), Pinia Colada, and more. | ||||||||||||||
| - **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms. | ||||||||||||||
| - **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators. | ||||||||||||||
| - **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more. | ||||||||||||||
| - **⏱️ Lazy Router**: Enhance cold start times with our lazy routing feature. | ||||||||||||||
| - **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming. | ||||||||||||||
| - **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond. | ||||||||||||||
| - **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors. | ||||||||||||||
| - **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed. | ||||||||||||||
|
|
||||||||||||||
| ## Documentation | ||||||||||||||
|
|
||||||||||||||
| You can find the full documentation [here](https://orpc.unnoq.com). | ||||||||||||||
|
|
||||||||||||||
| ## Packages | ||||||||||||||
|
|
||||||||||||||
| - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract. | ||||||||||||||
| - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract. | ||||||||||||||
| - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety. | ||||||||||||||
| - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests. | ||||||||||||||
| - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/). | ||||||||||||||
| - [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions. | ||||||||||||||
| - [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration. | ||||||||||||||
| - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/). | ||||||||||||||
| - [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration. | ||||||||||||||
| - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet. | ||||||||||||||
| - [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/). | ||||||||||||||
| - [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/). | ||||||||||||||
|
|
||||||||||||||
| ## `@orpc/json-schema-typed` | ||||||||||||||
|
|
||||||||||||||
| Re-export of [json-schema-typed](https://www.npmjs.com/package/json-schema-typed) due to the upstream issue [RemyRylan/json-schema-typed#116](https://github.com/RemyRylan/json-schema-typed/issues/116). | ||||||||||||||
|
|
||||||||||||||
| ## Sponsors | ||||||||||||||
|
|
||||||||||||||
| <p align="center"> | ||||||||||||||
| <a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg"> | ||||||||||||||
| <img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/> | ||||||||||||||
| </a> | ||||||||||||||
| </p> | ||||||||||||||
|
|
||||||||||||||
| ## License | ||||||||||||||
|
|
||||||||||||||
| Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information. | ||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { defineBuildConfig } from 'unbuild' | ||
|
|
||
| export default defineBuildConfig({ | ||
| rollup: { | ||
| inlineDependencies: ['json-schema-typed'], | ||
| }, | ||
| }) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,57 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "name": "@orpc/json-schema-typed", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "type": "module", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "version": "0.0.0", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "license": "MIT", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "homepage": "https://orpc.unnoq.com", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "repository": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "type": "git", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "url": "git+https://github.com/unnoq/orpc.git", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "directory": "packages/json-schema-typed" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "keywords": [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "unnoq", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "orpc" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "publishConfig": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "exports": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ".": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "types": "./dist/index.d.mts", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "import": "./dist/index.mjs", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "default": "./dist/index.mjs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "./draft-07": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "types": "./dist/draft-07.d.mts", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "import": "./dist/draft-07.mjs", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "default": "./dist/draft-07.mjs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "./draft-2019-09": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "types": "./dist/draft-2019-09.d.mts", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "import": "./dist/draft-2019-09.mjs", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "default": "./dist/draft-2019-09.mjs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "./draft-2020-12": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "types": "./dist/draft-2020-12.d.mts", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "import": "./dist/draft-2020-12.mjs", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "default": "./dist/draft-2020-12.mjs" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "exports": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ".": "./src/index.ts", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "./draft-07": "./src/draft-07.ts", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "./draft-2019-09": "./src/draft-2019-09.ts", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "./draft-2020-12": "./src/draft-2020-12.ts" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "files": [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "dist" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "scripts": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "build": "unbuild", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "build:watch": "pnpm run build --watch", | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "type:check": "tsc -b" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "devDependencies": { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| "json-schema-typed": "^8.0.1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+49
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainEnsure no runtime dependency on
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 🏁 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 • In - 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 • In "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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // eslint-disable-next-line no-restricted-imports | ||
| export * from 'json-schema-typed/draft-07' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // eslint-disable-next-line no-restricted-imports | ||
| export * from 'json-schema-typed/draft-2019-09' | ||
|
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ 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 -// 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'
🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,2 @@ | ||||||||||||||||||||||||||||||||||||
| // eslint-disable-next-line no-restricted-imports | ||||||||||||||||||||||||||||||||||||
| export * from 'json-schema-typed/draft-2020-12' | ||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainUse type-only re-export to avoid runtime re-export and make erasableSyntaxOnly effective
-// 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 🏁 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: 💡 Result: TypeScript does not support the syntax Details:
Summary table:
TypeScript documentation confirms only named type re-exports are supported; wildcard type-only re-exports ( Citations:
Use named type‐only re-exports instead of a wildcard • File: packages/json-schema-typed/src/draft-2020-12.ts - // 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 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // eslint-disable-next-line no-restricted-imports | ||
| export * from 'json-schema-typed' | ||
|
Comment on lines
+1
to
+2
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Type-only re-export to ensure zero JS emission and fix erasableSyntaxOnly behavior Avoid emitting -// 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
🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "extends": "../../tsconfig.lib.json", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "include": ["src"], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "exclude": [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "**/*.test.*", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "**/*.test-d.ts", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "**/__tests__/**", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "**/__mocks__/**", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "**/__snapshots__/**" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainMake 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 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: 💡 Result: The TypeScript compiler option 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:
Example of disallowed syntax under // ❌ 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: For best results, it is recommended to pair Summary Table:
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."
fiLength of output: 453 Enable explicit type-only elision in your package tsconfig Your base config ( • 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 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||||||||
| /* eslint-disable no-restricted-imports */ | ||||||||||||
| import type { JSONSchema, keywords } from 'json-schema-typed/draft-2020-12' | ||||||||||||
| import { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from 'json-schema-typed/draft-2020-12' | ||||||||||||
| 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' | ||||||||||||
|
Comment on lines
+2
to
+3
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
-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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||
|
|
||||||||||||
| export { JSONSchemaContentEncoding, JSONSchemaFormat, JSONSchemaTypeName } | ||||||||||||
| export type { JSONSchema } | ||||||||||||
|
|
||||||||||||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.