type-fest
Advanced tools
Comparing version 4.13.1 to 4.14.0
@@ -10,2 +10,3 @@ // Basic | ||
export type {DistributedOmit} from './source/distributed-omit'; | ||
export type {DistributedPick} from './source/distributed-pick'; | ||
export type {EmptyObject, IsEmptyObject} from './source/empty-object'; | ||
@@ -12,0 +13,0 @@ export type {NonEmptyObject} from './source/non-empty-object'; |
{ | ||
"name": "type-fest", | ||
"version": "4.13.1", | ||
"version": "4.14.0", | ||
"description": "A collection of essential TypeScript types", | ||
@@ -19,4 +19,8 @@ "license": "(MIT OR CC0-1.0)", | ||
"scripts": { | ||
"test": "xo && tsd && tsc && npm run test:set-parameter-type && node script/test/source-files-extension.js", | ||
"test:set-parameter-type": "tsc --noEmit test-d/set-parameter-type" | ||
"test:set-parameter-type": "tsc --noEmit test-d/set-parameter-type", | ||
"test:source-files-extension": "node script/test/source-files-extension.js", | ||
"test:tsc": "tsc", | ||
"test:tsd": "tsd", | ||
"test:xo": "xo", | ||
"test": "run-p test:*" | ||
}, | ||
@@ -42,5 +46,6 @@ "files": [ | ||
"expect-type": "^0.15.0", | ||
"npm-run-all2": "^6.1.2", | ||
"tsd": "^0.28.1", | ||
"typescript": "^5.2.2", | ||
"xo": "^0.56.0" | ||
"xo": "^0.58.0" | ||
}, | ||
@@ -55,3 +60,10 @@ "xo": { | ||
"@typescript-eslint/no-confusing-void-expression": "off", | ||
"@typescript-eslint/no-unsafe-argument": "off" | ||
"@typescript-eslint/no-unsafe-argument": "off", | ||
"object-curly-newline": [ | ||
"error", | ||
{ | ||
"multiline": true, | ||
"consistent": true | ||
} | ||
] | ||
} | ||
@@ -58,0 +70,0 @@ }, |
@@ -186,2 +186,3 @@ <div align="center"> | ||
- [`DistributedOmit`](source/distributed-omit.d.ts) - Omits keys from a type, distributing the operation over a union. | ||
- [`DistributedPick`](source/distributed-pick.d.ts) - Picks keys from a type, distributing the operation over a union. | ||
@@ -188,0 +189,0 @@ ### Type Guard |
@@ -32,2 +32,2 @@ import type {SetReturnType} from './set-return-type'; | ||
*/ | ||
export type Asyncify<Fn extends (...arguments_: any[]) => any> = SetReturnType<Fn, Promise<Awaited<ReturnType<Fn>>>>; | ||
export type Asyncify<Function_ extends (...arguments_: any[]) => any> = SetReturnType<Function_, Promise<Awaited<ReturnType<Function_>>>>; |
@@ -101,3 +101,3 @@ import type {Primitive} from './primitive'; | ||
*/ | ||
export type NonRecursiveType = BuiltIns | Function | (new (...args: any[]) => unknown); | ||
export type NonRecursiveType = BuiltIns | Function | (new (...arguments_: any[]) => unknown); | ||
@@ -104,0 +104,0 @@ /** |
@@ -41,3 +41,3 @@ import type {BuiltIns, HasMultipleCallSignatures} from './internal'; | ||
? T | ||
: T extends new (...args: any[]) => unknown | ||
: T extends new (...arguments_: any[]) => unknown | ||
? T // Skip class constructors | ||
@@ -44,0 +44,0 @@ : T extends (...arguments_: any[]) => unknown |
@@ -107,12 +107,12 @@ import type {IsUnknown} from './is-unknown'; | ||
*/ | ||
export type SetParameterType<Fn extends (...arguments_: any[]) => unknown, P extends Record<number, unknown>> = | ||
export type SetParameterType<Function_ extends (...arguments_: any[]) => unknown, P extends Record<number, unknown>> = | ||
// Just using `Parameters<Fn>` isn't ideal because it doesn't handle the `this` fake parameter. | ||
Fn extends (this: infer ThisArg, ...arguments_: infer Arguments) => unknown | ||
Function_ extends (this: infer ThisArgument, ...arguments_: infer Arguments) => unknown | ||
? ( | ||
// If a function did not specify the `this` fake parameter, it will be inferred to `unknown`. | ||
// We want to detect this situation just to display a friendlier type upon hovering on an IntelliSense-powered IDE. | ||
IsUnknown<ThisArg> extends true | ||
? (...arguments_: MergeObjectToArray<Arguments, P>) => ReturnType<Fn> | ||
: (this: ThisArg, ...arguments_: MergeObjectToArray<Arguments, P>) => ReturnType<Fn> | ||
IsUnknown<ThisArgument> extends true | ||
? (...arguments_: MergeObjectToArray<Arguments, P>) => ReturnType<Function_> | ||
: (this: ThisArgument, ...arguments_: MergeObjectToArray<Arguments, P>) => ReturnType<Function_> | ||
) | ||
: Fn; // This part should be unreachable | ||
: Function_; // This part should be unreachable |
@@ -20,11 +20,11 @@ import type {IsUnknown} from './is-unknown'; | ||
*/ | ||
export type SetReturnType<Fn extends (...arguments_: any[]) => any, TypeToReturn> = | ||
export type SetReturnType<Function_ extends (...arguments_: any[]) => any, TypeToReturn> = | ||
// Just using `Parameters<Fn>` isn't ideal because it doesn't handle the `this` fake parameter. | ||
Fn extends (this: infer ThisArg, ...arguments_: infer Arguments) => any ? ( | ||
Function_ extends (this: infer ThisArgument, ...arguments_: infer Arguments) => any ? ( | ||
// If a function did not specify the `this` fake parameter, it will be inferred to `unknown`. | ||
// We want to detect this situation just to display a friendlier type upon hovering on an IntelliSense-powered IDE. | ||
IsUnknown<ThisArg> extends true ? (...arguments_: Arguments) => TypeToReturn : (this: ThisArg, ...arguments_: Arguments) => TypeToReturn | ||
IsUnknown<ThisArgument> extends true ? (...arguments_: Arguments) => TypeToReturn : (this: ThisArgument, ...arguments_: Arguments) => TypeToReturn | ||
) : ( | ||
// This part should be unreachable, but we make it meaningful just in case… | ||
(...arguments_: Parameters<Fn>) => TypeToReturn | ||
(...arguments_: Parameters<Function_>) => TypeToReturn | ||
); |
@@ -71,2 +71,3 @@ declare namespace TsConfigJson { | ||
// eslint-disable-next-line unicorn/prevent-abbreviations | ||
export type Lib = | ||
@@ -73,0 +74,0 @@ | 'ES5' |
356300
133
8561
971
6