@wix/sdk-types
Advanced tools
Comparing version 1.12.3 to 1.12.4
@@ -16,2 +16,6 @@ type HostModule<T, H extends Host> = { | ||
/** | ||
* Optional name of the environment, use for logging | ||
*/ | ||
name?: string; | ||
/** | ||
* Optional bast url to use for API requests, for example `www.wixapis.com` | ||
@@ -316,2 +320,68 @@ */ | ||
/** | ||
Returns a boolean for whether the given type is `never`. | ||
@link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919 | ||
@link https://stackoverflow.com/a/53984913/10292952 | ||
@link https://www.zhenghao.io/posts/ts-never | ||
Useful in type utilities, such as checking if something does not occur. | ||
@example | ||
``` | ||
import type {IsNever, And} from 'type-fest'; | ||
// https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts | ||
type AreStringsEqual<A extends string, B extends string> = | ||
And< | ||
IsNever<Exclude<A, B>> extends true ? true : false, | ||
IsNever<Exclude<B, A>> extends true ? true : false | ||
>; | ||
type EndIfEqual<I extends string, O extends string> = | ||
AreStringsEqual<I, O> extends true | ||
? never | ||
: void; | ||
function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> { | ||
if (input === output) { | ||
process.exit(0); | ||
} | ||
} | ||
endIfEqual('abc', 'abc'); | ||
//=> never | ||
endIfEqual('abc', '123'); | ||
//=> void | ||
``` | ||
@category Type Guard | ||
@category Utilities | ||
*/ | ||
type IsNever<T> = [T] extends [never] ? true : false; | ||
/** | ||
An if-else-like type that resolves depending on whether the given type is `never`. | ||
@see {@link IsNever} | ||
@example | ||
``` | ||
import type {IfNever} from 'type-fest'; | ||
type ShouldBeTrue = IfNever<never>; | ||
//=> true | ||
type ShouldBeBar = IfNever<'not never', 'foo', 'bar'>; | ||
//=> 'bar' | ||
``` | ||
@category Type Guard | ||
@category Utilities | ||
*/ | ||
type IfNever<T, TypeIfNever = true, TypeIfNotNever = false> = ( | ||
IsNever<T> extends true ? TypeIfNever : TypeIfNotNever | ||
); | ||
/** | ||
Extract the keys from a type where the value type of the key extends the given `Condition`. | ||
@@ -348,17 +418,15 @@ | ||
*/ | ||
type ConditionalKeys<Base, Condition> = NonNullable< | ||
// Wrap in `NonNullable` to strip away the `undefined` type from the produced union. | ||
type ConditionalKeys<Base, Condition> = | ||
{ | ||
// Map through all the keys of the given base type. | ||
[Key in keyof Base]: | ||
[Key in keyof Base]-?: | ||
// Pick only keys with types extending the given `Condition` type. | ||
Base[Key] extends Condition | ||
// Retain this key since the condition passes. | ||
? Key | ||
// Retain this key | ||
// If the value for the key extends never, only include it if `Condition` also extends never | ||
? IfNever<Base[Key], IfNever<Condition, Key, never>, Key> | ||
// Discard this key since the condition fails. | ||
: never; | ||
// Convert the produced object into a union type of the keys which passed the conditional test. | ||
}[keyof Base] | ||
>; | ||
}[keyof Base]; | ||
@@ -365,0 +433,0 @@ /** |
{ | ||
"name": "@wix/sdk-types", | ||
"version": "1.12.3", | ||
"version": "1.12.4", | ||
"license": "UNLICENSED", | ||
@@ -31,8 +31,8 @@ "author": { | ||
"devDependencies": { | ||
"@types/node": "^20.10.6", | ||
"eslint": "^8.56.0", | ||
"@types/node": "^20.17.1", | ||
"eslint": "^8.57.1", | ||
"eslint-config-sdk": "0.0.0", | ||
"tsup": "^7.3.0", | ||
"type-fest": "^4.9.0", | ||
"typescript": "^5.3.3" | ||
"type-fest": "^4.26.1", | ||
"typescript": "^5.6.3" | ||
}, | ||
@@ -62,3 +62,3 @@ "yoshiFlowLibrary": { | ||
}, | ||
"falconPackageHash": "752e0b1c726af0c96999550c6ce6651d0466c9972e8a1f5d4ae8439f" | ||
"falconPackageHash": "8469d4de3131c4bcc8fc47df34db04866cf00b50a23e8a32eb180346" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39243
542