Skip to content

Commit 8888c38

Browse files
authored
Merge pull request #43 from nobrainr/fix/allow-partial-completion-for-currying-function
fix: allow partial completion for currying function
2 parents c7d4f54 + 6076c89 commit 8888c38

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/morphism.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,11 @@ export function morphism<
302302
TSchema extends Schema<Destination, Source> = Schema<Destination, Source>
303303
>(schema: TSchema, data: Source): ResultItem<TSchema>;
304304

305-
export function morphism<TSchema extends Schema>(schema: TSchema): Mapper<TSchema>; // morphism({}) => mapper(S) => T
305+
export function morphism<
306+
Destination,
307+
Source = any,
308+
TSchema extends Schema<Destination, Source> = Schema<Destination, Source>
309+
>(schema: TSchema): Mapper<TSchema>; // morphism({}) => mapper(S) => T
306310

307311
export function morphism<TSchema extends Schema, TDestination>(
308312
schema: TSchema,

src/typescript.spec.ts

+4
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ describe('Morphism', () => {
8888

8989
const d = morphism<Destination>({ namingIsHard: 'boring_api_field' }, { boring_api_field: 2 });
9090
d.namingIsHard;
91+
92+
morphism({ namingIsHard: 'boring_api_field' });
93+
morphism<Destination, Source>({ namingIsHard: 'boring_api_field' })({ boring_api_field: 2 });
94+
morphism<Destination>({ namingIsHard: 'boring_api_field' })([{ boring_api_field: 2 }]).pop().namingIsHard;
9195
});
9296
});
9397
});

0 commit comments

Comments
 (0)