inferred-types 0.29.0 → 0.30.0

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
@@ -986,6 +986,8 @@ declare type Mapper<I, O, C extends FinalizedMapConfig<OptRequired, MapCardinali
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inferred-types",
3
- "version": "0.29.0",
3
+ "version": "0.30.0",
4
4
  "description": "Functions which provide useful type inference on TS projects",
5
5
  "license": "MIT",
6
6
  "author": "Ken Snyder<ken@ken.net>",
@@ -382,4 +382,6 @@ export type Mapper<
382
382
  output: MapOR<C>;
383
383
  cardinality: MapCard<C>;
384
384
  debug: boolean | string;
385
+ inputType: I;
386
+ outputType: O;
385
387
  } & MapFn<I, O, C>;
@@ -116,6 +116,8 @@ const mapper =
116
116
  output: config.output,
117
117
  cardinality: config.cardinality,
118
118
  debug: config.debug,
119
+ inputType: {} as I,
120
+ outputType: {} as O,
119
121
  });
120
122
  };
121
123
 
@@ -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", () => {