@@ -2023,37 +2023,37 @@ export type SerializableTypeId = "~effect-atom/atom/Atom/Serializable"
20232023 * @since 1.0.0
20242024 * @category Serializable
20252025 */
2026- export interface Serializable {
2026+ export interface Serializable < S extends Schema . Schema . Any > {
20272027 readonly [ SerializableTypeId ] : {
20282028 readonly key : string
2029- readonly encode : ( value : unknown ) = > unknown
2030- readonly decode : ( value : unknown ) = > unknown
2029+ readonly encode : ( value : S [ "Type" ] ) => S [ "Encoded" ]
2030+ readonly decode : ( value : S [ "Encoded" ] ) => S [ "Type" ]
20312031 }
20322032}
20332033
20342034/**
20352035 * @since 1.0.0
20362036 * @category Serializable
20372037 */
2038- export const isSerializable = ( self : Atom < any > ) : self is Atom < any > & Serializable => SerializableTypeId in self
2038+ export const isSerializable = ( self : Atom < any > ) : self is Atom < any > & Serializable < any > => SerializableTypeId in self
20392039
20402040/**
20412041 * @since 1.0.0
20422042 * @category combinators
20432043 */
20442044export const serializable : {
2045- < R extends Atom < any > , I > ( options : {
2045+ < R extends Atom < any > , S extends Schema . Schema < Type < R > , any > > ( options : {
20462046 readonly key : string
2047- readonly schema : Schema . Schema < Type < R > , I >
2048- } ) : ( self : R ) = > R & Serializable
2049- < R extends Atom < any > , I > ( self : R , options : {
2047+ readonly schema : S
2048+ } ) : ( self : R ) => R & Serializable < S >
2049+ < R extends Atom < any > , S extends Schema . Schema < Type < R > , any > > ( self : R , options : {
20502050 readonly key : string
2051- readonly schema : Schema . Schema < Type < R > , I >
2052- } ) : R & Serializable
2051+ readonly schema : S
2052+ } ) : R & Serializable < S >
20532053} = dual ( 2 , < R extends Atom < any > , A , I > ( self : R , options : {
20542054 readonly key : string
20552055 readonly schema : Schema . Schema < A , I >
2056- } ) : R & Serializable =>
2056+ } ) : R & Serializable < any > =>
20572057 Object . assign ( Object . create ( Object . getPrototypeOf ( self ) ) , {
20582058 ...self ,
20592059 label : self . label ?? [ options . key , new Error ( ) . stack ?. split ( "\n" ) [ 5 ] ?? "" ] ,
0 commit comments