inferred-types 0.29.0 → 0.30.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
|
@@ -981,11 +981,13 @@ declare type MapFn<I, O, C extends FinalizedMapConfig<OptRequired, MapCardinalit
|
|
|
981
981
|
* const mappedOver = inputs.map(m);
|
|
982
982
|
* ```
|
|
983
983
|
*/
|
|
984
|
-
declare type Mapper<I, O, C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = {
|
|
984
|
+
declare type Mapper<I = unknown, O = unknown, C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired> = FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = {
|
|
985
985
|
input: MapIR<C>;
|
|
986
986
|
output: MapOR<C>;
|
|
987
987
|
cardinality: MapCard<C>;
|
|
988
988
|
debug: boolean | string;
|
|
989
|
+
inputType: I;
|
|
990
|
+
outputType: O;
|
|
989
991
|
} & MapFn<I, O, C>;
|
|
990
992
|
|
|
991
993
|
/**
|
package/dist/index.js
CHANGED
|
@@ -643,7 +643,9 @@ var mapper = (config) => (map) => {
|
|
|
643
643
|
input: config.input,
|
|
644
644
|
output: config.output,
|
|
645
645
|
cardinality: config.cardinality,
|
|
646
|
-
debug: config.debug
|
|
646
|
+
debug: config.debug,
|
|
647
|
+
inputType: {},
|
|
648
|
+
outputType: {}
|
|
647
649
|
});
|
|
648
650
|
};
|
|
649
651
|
var setMapper = (config = { input: void 0, output: void 0, cardinality: void 0 }, defaultValue) => ({
|
package/dist/index.mjs
CHANGED
|
@@ -552,7 +552,9 @@ var mapper = (config) => (map) => {
|
|
|
552
552
|
input: config.input,
|
|
553
553
|
output: config.output,
|
|
554
554
|
cardinality: config.cardinality,
|
|
555
|
-
debug: config.debug
|
|
555
|
+
debug: config.debug,
|
|
556
|
+
inputType: {},
|
|
557
|
+
outputType: {}
|
|
556
558
|
});
|
|
557
559
|
};
|
|
558
560
|
var setMapper = (config = { input: void 0, output: void 0, cardinality: void 0 }, defaultValue) => ({
|
package/package.json
CHANGED
|
@@ -374,12 +374,18 @@ export type MapFn<
|
|
|
374
374
|
* ```
|
|
375
375
|
*/
|
|
376
376
|
export type Mapper<
|
|
377
|
-
I,
|
|
378
|
-
O,
|
|
379
|
-
C extends FinalizedMapConfig<
|
|
377
|
+
I = unknown,
|
|
378
|
+
O = unknown,
|
|
379
|
+
C extends FinalizedMapConfig<
|
|
380
|
+
OptRequired,
|
|
381
|
+
MapCardinalityIllustrated,
|
|
382
|
+
OptRequired
|
|
383
|
+
> = FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>
|
|
380
384
|
> = {
|
|
381
385
|
input: MapIR<C>;
|
|
382
386
|
output: MapOR<C>;
|
|
383
387
|
cardinality: MapCard<C>;
|
|
384
388
|
debug: boolean | string;
|
|
389
|
+
inputType: I;
|
|
390
|
+
outputType: O;
|
|
385
391
|
} & MapFn<I, O, C>;
|
|
@@ -262,6 +262,12 @@ describe("mapTo() utility function", () => {
|
|
|
262
262
|
expect(m1.output).toBe("req");
|
|
263
263
|
expect(m1.cardinality).toBe("I -> O");
|
|
264
264
|
expect(m1(i)).toEqual(i);
|
|
265
|
+
|
|
266
|
+
type cases = [
|
|
267
|
+
Expect<Equal<typeof m1["inputType"], I>>, //
|
|
268
|
+
Expect<Equal<typeof m1["outputType"], I>> //
|
|
269
|
+
];
|
|
270
|
+
const cases: cases = [true, true];
|
|
265
271
|
});
|
|
266
272
|
|
|
267
273
|
it("M:1 conversion", () => {
|
|
@@ -309,9 +315,13 @@ describe("mapTo() utility function", () => {
|
|
|
309
315
|
.config({ output: "req", cardinality: "I -> O[]" })
|
|
310
316
|
.map<I, O>((i) => [{ title: i.title, count: i.products.length }]);
|
|
311
317
|
const o = m([i, i2]);
|
|
318
|
+
type RT = ReturnType<typeof m>;
|
|
312
319
|
|
|
313
320
|
expect(o.length).toBe(2);
|
|
314
321
|
o.map((item) => expect("title" in item).toBeTruthy());
|
|
322
|
+
|
|
323
|
+
type cases = [Expect<Equal<RT, O[] | [O, ...O[]]>>];
|
|
324
|
+
const cases: cases = [true];
|
|
315
325
|
});
|
|
316
326
|
|
|
317
327
|
it("1:M conversion with filtering", () => {
|