inferred-types 0.28.0 → 0.28.3

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
@@ -838,7 +838,7 @@ interface MapConfig<IR extends OptRequired | undefined = undefined, D extends Ma
838
838
  * Note: _this configuration does _not_ yet include the actual mapping
839
839
  * configuration between the input and output._
840
840
  */
841
- declare type FinalizedMapConfig<IR extends OptRequired, D extends MapCardinalityIllustrated, OR extends OptRequired> = Required<MapConfig<IR, D, OR>> & {
841
+ declare type FinalizedMapConfig<IR extends OptRequired = MapIR<DefaultOneToManyMapping>, D extends MapCardinalityIllustrated = MapCard<DefaultOneToManyMapping>, OR extends OptRequired = MapOR<DefaultOneToManyMapping>> = Required<MapConfig<IR, D, OR>> & {
842
842
  finalized: true;
843
843
  };
844
844
  /**
@@ -927,12 +927,13 @@ OR extends OptRequired, C extends MapCardinalityIllustrated> = C extends MapCard
927
927
  /**
928
928
  * **MapTo<I, O>**
929
929
  *
930
- * A mapping function between an input type `I` and output type `O`.
930
+ * A mapping function between an input type `I` and output type `O`. Defaults to using
931
+ * the _default_ OneToMany mapping config.
931
932
  *
932
933
  * **Note:** this type is designed to guide the userland mapping; refer
933
934
  * to `MapFn` if you want the type output by the `mapFn()` utility.
934
935
  */
935
- declare type MapTo<I, O, C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>> = MapIR<C> extends "opt" ? (source?: MapInput<I, MapIR<C>, MapCard<C>>) => MapOutput<O, MapOR<C>, MapCard<C>> : (source: MapInput<I, MapIR<C>, MapCard<C>>) => MapOutput<O, MapOR<C>, MapCard<C>>;
936
+ declare type MapTo<I, O, C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired> = DefaultOneToManyMapping> = MapIR<C> extends "opt" ? (source?: MapInput<I, MapIR<C>, MapCard<C>>) => MapOutput<O, MapOR<C>, MapCard<C>> : (source: MapInput<I, MapIR<C>, MapCard<C>>) => MapOutput<O, MapOR<C>, MapCard<C>>;
936
937
  declare type MapFnOutput<I, O, S, OR extends OptRequired, C extends MapCardinalityIllustrated> = C extends "I -> O[]" | MapCardinality.OneToMany ? S extends I[] ? OR extends "opt" ? O[] : [O, ...O[]] : OR extends "opt" ? O[] | null : O[] : C extends MapCardinality.OneToOne | "I -> O" ? S extends I[] ? OR extends "opt" ? O[] : [O, ...O[]] : OR extends "opt" ? O | null : O : C extends MapCardinality.ManyToOne | "I[] -> O" ? S extends I[][] ? OR extends "opt" ? O[] : [O, ...O[]] : OR extends "opt" ? O | null : O : never;
937
938
  declare type MapFnInput<I, IR extends OptRequired, D extends MapCardinalityIllustrated> = D extends "I -> O[]" | MapCardinality.OneToMany ? IR extends "opt" ? I | I[] | undefined : I | I[] : D extends MapCardinality.OneToOne | "I -> O" ? IR extends "opt" ? I | I[] | undefined : I | I[] : D extends MapCardinality.ManyToOne | "I[] -> O" ? IR extends "opt" ? I[] | I[][] | undefined : I[] | I[][] : never;
938
939
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inferred-types",
3
- "version": "0.28.0",
3
+ "version": "0.28.3",
4
4
  "description": "Functions which provide useful type inference on TS projects",
5
5
  "license": "MIT",
6
6
  "author": "Ken Snyder<ken@ken.net>",
@@ -45,9 +45,9 @@ export interface MapConfig<
45
45
  * configuration between the input and output._
46
46
  */
47
47
  export type FinalizedMapConfig<
48
- IR extends OptRequired,
49
- D extends MapCardinalityIllustrated,
50
- OR extends OptRequired
48
+ IR extends OptRequired = MapIR<DefaultOneToManyMapping>,
49
+ D extends MapCardinalityIllustrated = MapCard<DefaultOneToManyMapping>,
50
+ OR extends OptRequired = MapOR<DefaultOneToManyMapping>
51
51
  > = Required<MapConfig<IR, D, OR>> & { finalized: true };
52
52
 
53
53
  /**
@@ -252,7 +252,8 @@ export type MapOutput<
252
252
  /**
253
253
  * **MapTo<I, O>**
254
254
  *
255
- * A mapping function between an input type `I` and output type `O`.
255
+ * A mapping function between an input type `I` and output type `O`. Defaults to using
256
+ * the _default_ OneToMany mapping config.
256
257
  *
257
258
  * **Note:** this type is designed to guide the userland mapping; refer
258
259
  * to `MapFn` if you want the type output by the `mapFn()` utility.
@@ -260,7 +261,11 @@ export type MapOutput<
260
261
  export type MapTo<
261
262
  I,
262
263
  O,
263
- C extends FinalizedMapConfig<OptRequired, MapCardinalityIllustrated, OptRequired>
264
+ C extends FinalizedMapConfig<
265
+ OptRequired,
266
+ MapCardinalityIllustrated,
267
+ OptRequired
268
+ > = DefaultOneToManyMapping
264
269
  > = MapIR<C> extends "opt"
265
270
  ? (source?: MapInput<I, MapIR<C>, MapCard<C>>) => MapOutput<O, MapOR<C>, MapCard<C>>
266
271
  : (source: MapInput<I, MapIR<C>, MapCard<C>>) => MapOutput<O, MapOR<C>, MapCard<C>>;