diff --git a/package.json b/package.json index 6ae6df2..b64c161 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "typing-assets", - "version": "2.1.3", + "version": "2.1.4", "description": "Additional typing assets and helpers for better TypeScript experience", "main": "build/index.js", "types": "build/index.d.ts", diff --git a/src/functions/propertiesAggregation.ts b/src/functions/propertiesAggregation.ts index 6d7c20d..05729ba 100644 --- a/src/functions/propertiesAggregation.ts +++ b/src/functions/propertiesAggregation.ts @@ -6,7 +6,10 @@ */ export const excludeProperties = (source: TSource, ...args: TProp[]): Omit => { for (const key in source) { - if ([...args].includes(key as string as TProp )) delete source[key] + if ([...args].includes(key as string as TProp )) { + source[key] = undefined as any + delete source[key] + } } return source } @@ -20,7 +23,10 @@ export const excludeProperties = (source: */ export const pickProperties = (source: TSource, ...args: TProp[]): Pick => { for (const key in source) { - if (![...args].includes(key as string as TProp )) delete source[key] + if (![...args].includes(key as string as TProp )) { + source[key] = undefined as any + delete source[key] + } } return source } \ No newline at end of file diff --git a/src/utilityTypes/utility.ts b/src/utilityTypes/utility.ts index 9737fb2..13479e3 100644 --- a/src/utilityTypes/utility.ts +++ b/src/utilityTypes/utility.ts @@ -36,5 +36,15 @@ export declare type ExcludeActual = T extends object ? { [P in keyof T]: ExcludeActual } : Exclude - +/** + * @description Returns actual return type of function, resolving all promises and excluding nullables + */ export declare type ActualReturnType = T extends (args: any[]) => Promise ? ExcludeNullable>> : T extends (args: any[]) => any ? ExcludeNullable> : never + +/** + * @description Changes type of property(es) to provided type primitive + * @T Providing type + * @P Property which type will be replaced + * @C Replacing type + */ +export type ChangePropertyType = Omit & { [P in keyof T]: C } \ No newline at end of file