@@ -71,91 +71,109 @@ function defineParameterType<T, C extends Mocha.Context>(
7171 getRegistry ( ) . defineParameterType ( options ) ;
7272}
7373
74- function defineBefore ( options : ICaseHookOptions , fn : ICaseHookBody ) : void ;
75- function defineBefore ( fn : ICaseHookBody ) : void ;
76- function defineBefore (
77- optionsOrFn : ICaseHookBody | ICaseHookOptions ,
78- maybeFn ?: ICaseHookBody ,
74+ function defineBefore < C extends Mocha . Context > (
75+ options : ICaseHookOptions ,
76+ fn : ICaseHookBody < C > ,
77+ ) : void ;
78+ function defineBefore < C extends Mocha . Context > ( fn : ICaseHookBody < C > ) : void ;
79+ function defineBefore < C extends Mocha . Context > (
80+ optionsOrFn : ICaseHookBody < C > | ICaseHookOptions ,
81+ maybeFn ?: ICaseHookBody < C > ,
7982) {
8083 if ( typeof optionsOrFn === "function" ) {
81- getRegistry ( ) . defineBefore ( { } , optionsOrFn ) ;
84+ getRegistry < C , unknown [ ] > ( ) . defineBefore ( { } , optionsOrFn ) ;
8285 } else if ( typeof optionsOrFn === "object" && typeof maybeFn === "function" ) {
83- getRegistry ( ) . defineBefore ( optionsOrFn , maybeFn ) ;
86+ getRegistry < C , unknown [ ] > ( ) . defineBefore ( optionsOrFn , maybeFn ) ;
8487 } else {
8588 throw new Error ( "Unexpected argument for Before hook" ) ;
8689 }
8790}
8891
89- function defineAfter ( options : ICaseHookOptions , fn : ICaseHookBody ) : void ;
90- function defineAfter ( fn : ICaseHookBody ) : void ;
91- function defineAfter (
92- optionsOrFn : ICaseHookBody | ICaseHookOptions ,
93- maybeFn ?: ICaseHookBody ,
92+ function defineAfter < C extends Mocha . Context > (
93+ options : ICaseHookOptions ,
94+ fn : ICaseHookBody < C > ,
95+ ) : void ;
96+ function defineAfter < C extends Mocha . Context > ( fn : ICaseHookBody < C > ) : void ;
97+ function defineAfter < C extends Mocha . Context > (
98+ optionsOrFn : ICaseHookBody < C > | ICaseHookOptions ,
99+ maybeFn ?: ICaseHookBody < C > ,
94100) {
95101 if ( typeof optionsOrFn === "function" ) {
96- getRegistry ( ) . defineAfter ( { } , optionsOrFn ) ;
102+ getRegistry < C , unknown [ ] > ( ) . defineAfter ( { } , optionsOrFn ) ;
97103 } else if ( typeof optionsOrFn === "object" && typeof maybeFn === "function" ) {
98- getRegistry ( ) . defineAfter ( optionsOrFn , maybeFn ) ;
104+ getRegistry < C , unknown [ ] > ( ) . defineAfter ( optionsOrFn , maybeFn ) ;
99105 } else {
100106 throw new Error ( "Unexpected argument for After hook" ) ;
101107 }
102108}
103109
104- function defineBeforeStep ( options : IStepHookOptions , fn : IStepHookBody ) : void ;
105- function defineBeforeStep ( fn : IStepHookBody ) : void ;
106- function defineBeforeStep (
107- optionsOrFn : IStepHookBody | IStepHookOptions ,
108- maybeFn ?: IStepHookBody ,
110+ function defineBeforeStep < C extends Mocha . Context > (
111+ options : IStepHookOptions ,
112+ fn : IStepHookBody < C > ,
113+ ) : void ;
114+ function defineBeforeStep < C extends Mocha . Context > ( fn : IStepHookBody < C > ) : void ;
115+ function defineBeforeStep < C extends Mocha . Context > (
116+ optionsOrFn : IStepHookBody < C > | IStepHookOptions ,
117+ maybeFn ?: IStepHookBody < C > ,
109118) {
110119 if ( typeof optionsOrFn === "function" ) {
111- getRegistry ( ) . defineBeforeStep ( { } , optionsOrFn ) ;
120+ getRegistry < C , unknown [ ] > ( ) . defineBeforeStep ( { } , optionsOrFn ) ;
112121 } else if ( typeof optionsOrFn === "object" && typeof maybeFn === "function" ) {
113- getRegistry ( ) . defineBeforeStep ( optionsOrFn , maybeFn ) ;
122+ getRegistry < C , unknown [ ] > ( ) . defineBeforeStep ( optionsOrFn , maybeFn ) ;
114123 } else {
115124 throw new Error ( "Unexpected argument for BeforeStep hook" ) ;
116125 }
117126}
118127
119- function defineAfterStep ( options : IStepHookOptions , fn : IStepHookBody ) : void ;
120- function defineAfterStep ( fn : IStepHookBody ) : void ;
121- function defineAfterStep (
122- optionsOrFn : IStepHookBody | IStepHookOptions ,
123- maybeFn ?: IStepHookBody ,
128+ function defineAfterStep < C extends Mocha . Context > (
129+ options : IStepHookOptions ,
130+ fn : IStepHookBody < C > ,
131+ ) : void ;
132+ function defineAfterStep < C extends Mocha . Context > ( fn : IStepHookBody < C > ) : void ;
133+ function defineAfterStep < C extends Mocha . Context > (
134+ optionsOrFn : IStepHookBody < C > | IStepHookOptions ,
135+ maybeFn ?: IStepHookBody < C > ,
124136) {
125137 if ( typeof optionsOrFn === "function" ) {
126- getRegistry ( ) . defineAfterStep ( { } , optionsOrFn ) ;
138+ getRegistry < C , unknown [ ] > ( ) . defineAfterStep ( { } , optionsOrFn ) ;
127139 } else if ( typeof optionsOrFn === "object" && typeof maybeFn === "function" ) {
128- getRegistry ( ) . defineAfterStep ( optionsOrFn , maybeFn ) ;
140+ getRegistry < C , unknown [ ] > ( ) . defineAfterStep ( optionsOrFn , maybeFn ) ;
129141 } else {
130142 throw new Error ( "Unexpected argument for AfterStep hook" ) ;
131143 }
132144}
133145
134- function defineBeforeAll ( options : IRunHookOptions , fn : IRunHookBody ) : void ;
135- function defineBeforeAll ( fn : IRunHookBody ) : void ;
136- function defineBeforeAll (
137- optionsOrFn : IRunHookBody | IRunHookOptions ,
138- maybeFn ?: IRunHookBody ,
146+ function defineBeforeAll < C extends Mocha . Context > (
147+ options : IRunHookOptions ,
148+ fn : IRunHookBody < C > ,
149+ ) : void ;
150+ function defineBeforeAll < C extends Mocha . Context > ( fn : IRunHookBody < C > ) : void ;
151+ function defineBeforeAll < C extends Mocha . Context > (
152+ optionsOrFn : IRunHookBody < C > | IRunHookOptions ,
153+ maybeFn ?: IRunHookBody < C > ,
139154) {
140155 if ( typeof optionsOrFn === "function" ) {
141- getRegistry ( ) . defineBeforeAll ( { } , optionsOrFn ) ;
156+ getRegistry < C , unknown [ ] > ( ) . defineBeforeAll ( { } , optionsOrFn ) ;
142157 } else if ( typeof optionsOrFn === "object" && typeof maybeFn === "function" ) {
143- getRegistry ( ) . defineBeforeAll ( optionsOrFn , maybeFn ) ;
158+ getRegistry < C , unknown [ ] > ( ) . defineBeforeAll ( optionsOrFn , maybeFn ) ;
144159 } else {
145160 throw new Error ( "Unexpected argument for BeforeAll hook" ) ;
146161 }
147162}
148163
149- function defineAfterAll ( options : IRunHookOptions , fn : IRunHookBody ) : void ;
150- function defineAfterAll ( fn : IRunHookBody ) : void ;
151- function defineAfterAll (
152- optionsOrFn : IRunHookBody | IRunHookOptions ,
153- maybeFn ?: IRunHookBody ,
164+ function defineAfterAll < C extends Mocha . Context > (
165+ options : IRunHookOptions ,
166+ fn : IRunHookBody < C > ,
167+ ) : void ;
168+ function defineAfterAll < C extends Mocha . Context > ( fn : IRunHookBody < C > ) : void ;
169+ function defineAfterAll < C extends Mocha . Context > (
170+ optionsOrFn : IRunHookBody < C > | IRunHookOptions ,
171+ maybeFn ?: IRunHookBody < C > ,
154172) {
155173 if ( typeof optionsOrFn === "function" ) {
156- getRegistry ( ) . defineAfterAll ( { } , optionsOrFn ) ;
174+ getRegistry < C , unknown [ ] > ( ) . defineAfterAll ( { } , optionsOrFn ) ;
157175 } else if ( typeof optionsOrFn === "object" && typeof maybeFn === "function" ) {
158- getRegistry ( ) . defineAfterAll ( optionsOrFn , maybeFn ) ;
176+ getRegistry < C , unknown [ ] > ( ) . defineAfterAll ( optionsOrFn , maybeFn ) ;
159177 } else {
160178 throw new Error ( "Unexpected argument for AfterAll hook" ) ;
161179 }
0 commit comments