diff --git a/templates/$operation.d.ts b/templates/$operation.d.ts index c6c9e01..a135833 100644 --- a/templates/$operation.d.ts +++ b/templates/$operation.d.ts @@ -1,4 +1,4 @@ -import { Morphism } from './$types'; +import { Morphism, PropKey } from './$types'; export type DeepPartial = { [K in keyof T]?: DeepPartial }; @@ -6,13 +6,11 @@ export type DeepPartial = { [K in keyof T]?: DeepPartial }; export type Evolver = Morphism | { [K in keyof T]?: Evolver }; // from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766 -export type Diff = ({ - [P in T]: P -} & +export type Diff = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]; -export type Omit = Pick>; +export type Omit = Pick>; -export type Same = Diff< +export type Same = Diff< T | U, Diff | Diff >; diff --git a/templates/$types.d.ts b/templates/$types.d.ts index 4d49f37..5deaf17 100644 --- a/templates/$types.d.ts +++ b/templates/$types.d.ts @@ -2,6 +2,7 @@ export type Property = string | number | symbol; export type Path = List; +export type PropKey = keyof any; // for backward compatibility (keyofStringsOnly) // general @@ -14,12 +15,12 @@ export type IndexedListMorphism = ( index: number, list: List, ) => U; -export type IndexedObjectMorphism = ( +export type IndexedObjectMorphism = ( value: T, index: number, object: Record, ) => U; -export type KeyedObjectMorphism = ( +export type KeyedObjectMorphism = ( value: T, key: K, object: Record, diff --git a/templates/dissoc.d.ts b/templates/dissoc.d.ts index de116c9..301c094 100644 --- a/templates/dissoc.d.ts +++ b/templates/dissoc.d.ts @@ -1,11 +1,11 @@ import { Omit } from './$operation'; -import { Property } from './$types'; +import { Property, PropKey } from './$types'; export function $keyof( property: K, object: T, ): Omit; -export function $record, V extends PropertyKey>( +export function $record, V extends PropKey>( property: V, object: U, ): Omit;