fix(fetchium): Fix declaration emit and rest subpath for downstream consumers - #1
Merged
jimmy-phantom merged 2 commits intoApr 7, 2026
Conversation
Export `TypeDefSymbol` from types.ts so downstream consumers can emit .d.ts files without TS4029 errors when using TypeDef<T> in public type positions, such as when extending Entity. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
jimmy-phantom
force-pushed
the
fetchium/export-typedef-symbol
branch
from
April 6, 2026 17:05
7fb6458 to
4c8c2db
Compare
Replace unique symbol brand with string brand to fix TS4029 errors during declaration emit in downstream packages. TypeScript's declaration emitter cannot reference unique symbols across package boundaries (microsoft/TypeScript#56107), causing "cannot be named" errors for any consumer compiling with declaration: true. Also add the rest subpath entry to the Vite build config so that fetchium/rest produces runtime JS bundles at the paths declared in package.json exports. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
pzuraq
approved these changes
Apr 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
declaration: true. Replaced theunique symbolbrand onTypeDef<T>with a string literal brand (__fetchiumTypeDef). TypeScript's declaration emitter cannot referenceunique symbolacross package boundaries (microsoft/TypeScript#56107), causing "cannot be named" errors whenever a combinator liket.optional()is used in an exported class.restsubpath to Vite build so thatfetchium/restproduces runtime JS bundles. Thepackage.jsonexports declared./restbut no JS was being built for it.Changes
packages/fetchium/src/types.ts— Replaceunique symbolbrand with string brandpackages/fetchium/src/typeDefs.ts— CastdefineObjectassignment to fixRecord<string, TypeDef>constraint mismatch caused by string brandpackages/fetchium/vite.config.ts— Addrest/indexentry pointVerification
npm run buildsucceeds, producingrest/index.jsfor all output variants@phantom/fetchium-clientcompiles withdeclaration: trueproducing zero errors (was 367 TS4029 errors before)Trade-off
String brands are slightly weaker than
unique symbol(another library could theoretically define a type with__fetchiumTypeDef), but no real-world collisions have been reported for any library using this pattern (Drizzle ORM, ArkType, fp-ts, TypeScript compiler itself all use string brands). Theunique symbolapproach is fundamentally incompatible with TypeScript's declaration emitter for inferred types across package boundaries.🤖 Generated with Claude Code