File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,29 @@ describe("FastEvent元数据类型检查", () => {
1717 b : string
1818 c : boolean
1919 }
20+ test ( "未指定元数据类型" , ( ) => {
21+ const emitter = new FastEvent ( )
22+ type cases = [
23+ Expect < Equal < typeof emitter . options . meta , Record < string , any > > >
24+ ]
25+ emitter . on ( "x" , ( message ) => {
26+ type cases = [
27+ Expect < Equal < typeof message . meta , FastEventMeta & Record < string , any > > >
28+ ]
29+ } )
30+ emitter . once ( "x" , ( message ) => {
31+ type cases = [
32+ Expect < Equal < typeof message . meta , FastEventMeta & Record < string , any > > >
33+ ]
34+ } )
35+
36+ emitter . onAny ( ( message ) => {
37+ type cases = [
38+ Expect < Equal < typeof message . meta , FastEventMeta & Record < string , any > > >
39+ ]
40+ } )
41+ } )
42+
2043 test ( "全局元数据类型" , ( ) => {
2144 const emitter = new FastEvent < CustomEvents , CustomMeta > ( )
2245 type cases = [
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ export type FastEventEmitMessage<
3232 [ K in keyof Events ] : {
3333 type : Exclude < K , number | symbol >
3434 payload ?: Events [ K ]
35- meta ?: Partial < FastEventMeta > & M & Record < string , any >
35+ meta ?: DeepPartial < FastEventMeta & M & Record < string , any > >
3636 }
3737 } [ Exclude < keyof Events , number | symbol > ]
3838) & FaseEventMessageExtends
@@ -162,7 +162,7 @@ export type FastEventListenOptions<
162162
163163export type FastEventListenerArgs < M = Record < string , any > > = {
164164 retain ?: boolean ;
165- meta ?: Partial < M > & Record < string , any > ;
165+ meta ?: DeepPartial < M > & Record < string , any > ;
166166 abortSignal ?: AbortSignal ; // 用于传递给监听器函数
167167 /**
168168 *
You can’t perform that action at this time.
0 commit comments