Parameters
#
introductionImplement the built-in Parameters generic without using it.
View on GitHub#
start pointtsTry
/* _____________ Your Code Here _____________ */typeMyParameters <T extends (...args : any[]) => any> = any;Â/* _____________ Test Cases _____________ */constfoo = (arg1 : string,arg2 : number): void => {};constbar = (arg1 : boolean,arg2 : {a : 'A' }): void => {};constbaz = (): void => {};Âtypecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <MyParameters <typeoffoo >, [string, number]>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <MyParameters <typeofbar >, [boolean, {a : 'A' }]>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <MyParameters <typeofbaz >, []>>];
take the challengetsTry
/* _____________ Your Code Here _____________ */typeMyParameters <T extends (...args : any[]) => any> = any;Â/* _____________ Test Cases _____________ */constfoo = (arg1 : string,arg2 : number): void => {};constbar = (arg1 : boolean,arg2 : {a : 'A' }): void => {};constbaz = (): void => {};Âtypecases = [Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <MyParameters <typeoffoo >, [string, number]>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <MyParameters <typeofbar >, [boolean, {a : 'A' }]>>,Type 'false' does not satisfy the constraint 'true'.2344Type 'false' does not satisfy the constraint 'true'.Expect <Equal <MyParameters <typeofbaz >, []>>];