@@ -291,32 +291,35 @@ export interface Mapper<TSchema extends Schema | StrictSchema, TResult = ResultI
291291 * @param { } type
292292 *
293293 */
294- export function morphism < TSchema extends Schema , Source extends object > (
294+ export function morphism < TSchema extends Schema , Source extends SourceFromSchema < TSchema > > (
295295 schema : TSchema ,
296296 data : Source
297- ) : Source extends ( infer _C ) [ ] ? ResultItem < TSchema > [ ] : ResultItem < TSchema > ;
297+ ) : Source extends any [ ] ? ResultItem < TSchema > [ ] : ResultItem < TSchema > ;
298298
299- // morphism({}) => mapper(S) => T
300- export function morphism < TSchema extends Schema > ( schema : TSchema ) : Mapper < TSchema > ;
299+ export function morphism < TSchema extends Schema , Source extends SourceFromSchema < TSchema > > (
300+ schema : TSchema ,
301+ data : Source [ ]
302+ ) : ResultItem < TSchema > [ ] ;
303+
304+ export function morphism < TSchema extends Schema > ( schema : TSchema ) : Mapper < TSchema > ; // morphism({}) => mapper(S) => T
301305
302- // morphism({}, null, T) => mapper(S) => T
303306export function morphism < TSchema extends Schema , TDestination > (
304307 schema : TSchema ,
305308 items : null ,
306309 type : Constructable < TDestination >
307- ) : Mapper < TSchema , TDestination > ;
310+ ) : Mapper < TSchema , TDestination > ; // morphism({}, null, T) => mapper(S) => T
308311
309- // morphism({}, {}, T) => T
310312export function morphism < TSchema extends Schema , Target > (
311313 schema : TSchema ,
312314 items : SourceFromSchema < TSchema > ,
313315 type : Constructable < Target >
314- ) : Target ;
316+ ) : Target ; // morphism({}, {}, T) => T
317+
315318export function morphism < Target , Source , TSchema extends Schema < Target , Source > > (
316319 schema : TSchema ,
317320 items ?: SourceFromSchema < TSchema > ,
318321 type ?: Constructable < Target >
319- ) {
322+ ) : any {
320323 if ( items === undefined && type === undefined ) {
321324 return transformItems ( schema ) ;
322325 } else if ( schema && items && type ) {
0 commit comments