Skip to content

Commit 610f77f

Browse files
fix(fetchium): Fix declaration emit and rest subpath for downstream consumers (#1)
* fix(fetchium): Export TypeDefSymbol for declaration emit 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> * fix(fetchium): Fix declaration emit for downstream consumers 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> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b24a982 commit 610f77f

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"fetchium": patch
3+
---
4+
5+
Export `TypeDefSymbol` so downstream consumers can emit `.d.ts` files without TS4029 errors when using `TypeDef<T>` in public type positions, such as when extending `Entity`.

packages/fetchium/src/typeDefs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ export const t: APITypes = {
950950
null: Mask.NULL as unknown as TypeDef<null>,
951951
undefined: Mask.UNDEFINED as unknown as TypeDef<undefined>,
952952
array: defineArray,
953-
object: defineObject,
953+
object: defineObject as APITypes['object'],
954954
record: defineRecord,
955955
union: defineUnion,
956956
nullish: defineNullish,

packages/fetchium/src/types.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,16 @@ export interface CaseInsensitiveEnumSet<T extends string | boolean | number> ext
123123
// Public Branded TypeDef
124124
// ================================
125125

126-
declare const TypeDefSymbol: unique symbol;
127-
128126
/**
129127
* Branded phantom type representing a type definition in the public API.
130128
* At runtime, values are Masks, Sets, ValidatorDefs, etc. but the type system
131129
* sees them as TypeDef<T> where T is the extracted TypeScript type.
130+
*
131+
* Uses a string brand instead of unique symbol to avoid TS4029 errors
132+
* during declaration emit in downstream packages.
133+
* See: https://github.com/microsoft/TypeScript/issues/56107
132134
*/
133-
export type TypeDef<T = unknown> = T & { readonly [TypeDefSymbol]: T };
135+
export type TypeDef<T = unknown> = T & { readonly __fetchiumTypeDef: T };
134136

135137
// ================================
136138
// Internal Type Definitions

packages/fetchium/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default defineConfig({
2020
'stores/sync': resolve(__dirname, 'src/stores/sync.ts'),
2121
'subscriptions/polling': resolve(__dirname, 'src/subscriptions/polling.ts'),
2222
'topic/index': resolve(__dirname, 'src/topic/index.ts'),
23+
'rest/index': resolve(__dirname, 'src/rest/index.ts'),
2324
},
2425
formats: ['es', 'cjs'],
2526
},

0 commit comments

Comments
 (0)