Compare commits

...

1 Commits

Author SHA1 Message Date
Guido D'Orsi
b01cc1fe9d fix(typescript): fix type error on ItemsSym 2025-01-23 19:21:29 +01:00
3 changed files with 14 additions and 4 deletions

View File

@@ -0,0 +1,5 @@
---
"jazz-tools": patch
---
Switches from symbols to prefixes strings for private properties

View File

@@ -5,6 +5,7 @@ import {
type CoValueClass,
CoValueFromRaw,
ItemsSym,
JazzToolsSymbol,
MembersSym,
SchemaInit,
isCoValueClass,
@@ -23,7 +24,9 @@ export type CoMarker = { readonly __co: unique symbol };
export type co<T> = T | (T & CoMarker);
export type IfCo<C, R> = C extends infer _A | infer B
? B extends CoMarker
? R
? R extends JazzToolsSymbol // Exclude symbol properties like co.items or co.members from the refs/init types
? never
: R
: never
: never;
export type UnCo<T> = T extends co<infer A> ? A : T;

View File

@@ -1,8 +1,10 @@
export const SchemaInit = Symbol.for("SchemaInit");
export type JazzToolsSymbol = SchemaInit | ItemsSym | MembersSym;
export const SchemaInit = "$SchemaInit$";
export type SchemaInit = typeof SchemaInit;
export const ItemsSym = Symbol.for("items");
export const ItemsSym = "$items$";
export type ItemsSym = typeof ItemsSym;
export const MembersSym = Symbol.for("members");
export const MembersSym = "$members$";
export type MembersSym = typeof MembersSym;