@@ -33,11 +33,11 @@ type TrackFn = (deps: AnyFunction[], fn: VoidFunction) => void
3333export interface BindableParams < T > {
3434 defaultValue ?: T | undefined
3535 value ?: T | undefined
36- hash ?: ( a : T ) => string
37- isEqual ?: ( a : T , b : T | undefined ) => boolean
38- onChange ?: ( value : T , prev : T | undefined ) => void
39- debug ?: string
40- sync ?: boolean
36+ hash ?: ( ( a : T ) => string ) | undefined
37+ isEqual ?: ( ( a : T , b : T | undefined ) => boolean ) | undefined
38+ onChange ?: ( ( value : T , prev : T | undefined ) => void ) | undefined
39+ debug ?: string | undefined
40+ sync ?: boolean | undefined
4141}
4242
4343export type ValueOrFn < T > = T | ( ( prev : T ) => T )
@@ -86,8 +86,8 @@ export interface Scope {
8686}
8787
8888type EventType < T = any > = T & {
89- previousEvent ?: T & { [ key : string ] : any }
90- src ?: string
89+ previousEvent ?: ( T & { [ key : string ] : any } ) | undefined
90+ src ?: string | undefined
9191 [ key : string ] : any
9292}
9393
@@ -118,10 +118,10 @@ export interface Params<T extends Dict> {
118118export type GuardFn < T extends Dict > = ( params : Params < T > ) => boolean
119119
120120export interface Transition < T extends Dict > {
121- target ?: T [ "state" ]
122- actions ?: T [ "action" ] [ ]
123- guard ?: T [ "guard" ] | GuardFn < T >
124- reenter ?: boolean
121+ target ?: T [ "state" ] | undefined
122+ actions ?: T [ "action" ] [ ] | undefined
123+ guard ?: T [ "guard" ] | GuardFn < T > | undefined
124+ reenter ?: boolean | undefined
125125}
126126
127127type MaybeArray < T > = T | T [ ]
@@ -145,45 +145,61 @@ export type ActionsOrFn<T extends Dict> = T["action"][] | ((params: Params<T>) =
145145export type EffectsOrFn < T extends Dict > = T [ "effect" ] [ ] | ( ( params : Params < T > ) => T [ "effect" ] [ ] | undefined )
146146
147147export interface Machine < T extends Dict > {
148- debug ?: boolean
149- props ?: ( params : PropsParams < T > ) => T [ "props" ]
150- context ?: ( params : ContextParams < T > ) => {
151- [ K in keyof T [ "context" ] ] : Bindable < T [ "context" ] [ K ] >
152- }
153- computed ?: {
154- [ K in keyof T [ "computed" ] ] : ( params : ComputedParams < T > ) => T [ "computed" ] [ K ]
155- }
148+ debug ?: boolean | undefined
149+ props ?: ( ( params : PropsParams < T > ) => T [ "props" ] ) | undefined
150+ context ?:
151+ | ( ( params : ContextParams < T > ) => {
152+ [ K in keyof T [ "context" ] ] : Bindable < T [ "context" ] [ K ] >
153+ } )
154+ | undefined
155+ computed ?:
156+ | {
157+ [ K in keyof T [ "computed" ] ] : ( params : ComputedParams < T > ) => T [ "computed" ] [ K ]
158+ }
159+ | undefined
156160 initialState : ( params : { prop : PropFn < T > } ) => T [ "state" ]
157- entry ?: ActionsOrFn < T >
158- exit ?: ActionsOrFn < T >
159- effects ?: EffectsOrFn < T >
160- refs ?: ( params : RefsParams < T > ) => T [ "refs" ]
161- watch ?: ( params : Params < T > ) => void
162- on ?: {
163- [ E in T [ "event" ] [ "type" ] ] ?: Transition < T > | Array < Transition < T > >
164- }
165- states : {
166- [ K in T [ "state" ] ] : {
167- tags ?: T [ "tag" ] [ ]
168- entry ?: ActionsOrFn < T >
169- exit ?: ActionsOrFn < T >
170- effects ?: EffectsOrFn < T >
171- on ?: {
161+ entry ?: ActionsOrFn < T > | undefined
162+ exit ?: ActionsOrFn < T > | undefined
163+ effects ?: EffectsOrFn < T > | undefined
164+ refs ?: ( ( params : RefsParams < T > ) => T [ "refs" ] ) | undefined
165+ watch ?: ( ( params : Params < T > ) => void ) | undefined
166+ on ?:
167+ | {
172168 [ E in T [ "event" ] [ "type" ] ] ?: Transition < T > | Array < Transition < T > >
173169 }
170+ | undefined
171+ states : {
172+ [ K in T [ "state" ] ] : {
173+ tags ?: T [ "tag" ] [ ] | undefined
174+ entry ?: ActionsOrFn < T > | undefined
175+ exit ?: ActionsOrFn < T > | undefined
176+ effects ?: EffectsOrFn < T > | undefined
177+ on ?:
178+ | {
179+ [ E in T [ "event" ] [ "type" ] ] ?: Transition < T > | Array < Transition < T > >
180+ }
181+ | undefined
174182 }
175183 }
176- implementations ?: {
177- guards ?: {
178- [ K in T [ "guard" ] ] : ( params : Params < T > ) => boolean
179- }
180- actions ?: {
181- [ K in T [ "action" ] ] : ( params : Params < T > ) => void
182- }
183- effects ?: {
184- [ K in T [ "effect" ] ] : ( params : Params < T > ) => void | VoidFunction
185- }
186- }
184+ implementations ?:
185+ | {
186+ guards ?:
187+ | {
188+ [ K in T [ "guard" ] ] : ( params : Params < T > ) => boolean
189+ }
190+ | undefined
191+ actions ?:
192+ | {
193+ [ K in T [ "action" ] ] : ( params : Params < T > ) => void
194+ }
195+ | undefined
196+ effects ?:
197+ | {
198+ [ K in T [ "effect" ] ] : ( params : Params < T > ) => void | VoidFunction
199+ }
200+ | undefined
201+ }
202+ | undefined
187203}
188204
189205interface MachineBaseProps {
@@ -194,16 +210,16 @@ interface MachineBaseProps {
194210}
195211
196212export interface MachineSchema {
197- props ?: MachineBaseProps
198- context ?: Record < string , any >
199- refs ?: Record < string , any >
200- computed ?: Record < string , any >
201- state ?: string
202- tag ?: string
203- guard ?: string
204- action ?: string
205- effect ?: string
206- event ?: { type : string } & Dict
213+ props ?: MachineBaseProps | undefined
214+ context ?: Record < string , any > | undefined
215+ refs ?: Record < string , any > | undefined
216+ computed ?: Record < string , any > | undefined
217+ state ?: string | undefined
218+ tag ?: string | undefined
219+ guard ?: string | undefined
220+ action ?: string | undefined
221+ effect ?: string | undefined
222+ event ?: ( { type : string } & Dict ) | undefined
207223}
208224
209225type State < T extends MachineSchema > = Bindable < T [ "state" ] > & {
0 commit comments