Comparing version 0.1.23 to 0.1.24
import {IsEqual} from './comparison'; | ||
import {Primitive} from './types'; | ||
@@ -8,3 +9,3 @@ // Extract keys | ||
TKey extends keyof TObject, | ||
TValue | ||
TValue, | ||
> = TKey extends keyof TObject | ||
@@ -19,3 +20,3 @@ ? TObject[TKey] extends TValue | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -30,3 +31,3 @@ ? TObject extends object | ||
TKey extends keyof TObject, | ||
TValue | ||
TValue, | ||
> = TKey extends keyof TObject | ||
@@ -41,3 +42,3 @@ ? TObject[TKey] extends TValue | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -52,3 +53,3 @@ ? TObject extends object | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -63,3 +64,3 @@ ? TObject extends object | ||
TKey extends keyof TObject, | ||
TValue | ||
TValue, | ||
> = TKey extends keyof TObject | ||
@@ -74,3 +75,3 @@ ? TValue extends TObject[TKey] | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -85,3 +86,3 @@ ? TObject extends object | ||
TKey extends keyof TObject, | ||
TValue | ||
TValue, | ||
> = TKey extends keyof TObject | ||
@@ -96,3 +97,3 @@ ? TValue extends TObject[TKey] | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -109,3 +110,3 @@ ? TObject extends object | ||
TKey extends keyof TObject, | ||
TValue | ||
TValue, | ||
> = TKey extends keyof TObject | ||
@@ -120,3 +121,3 @@ ? TObject[TKey] extends TValue | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -131,3 +132,3 @@ ? TObject extends object | ||
TKey extends keyof TObject, | ||
TValue | ||
TValue, | ||
> = TKey extends keyof TObject | ||
@@ -142,3 +143,3 @@ ? TObject[TKey] extends TValue | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -153,3 +154,3 @@ ? TObject extends object | ||
TKey extends keyof TObject, | ||
TValue | ||
TValue, | ||
> = TKey extends keyof TObject | ||
@@ -164,3 +165,3 @@ ? TValue extends TObject[TKey] | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -175,3 +176,3 @@ ? TObject extends object | ||
TKey extends keyof TObject, | ||
TValue | ||
TValue, | ||
> = TKey extends keyof TObject | ||
@@ -186,3 +187,3 @@ ? TValue extends TObject[TKey] | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -197,3 +198,3 @@ ? TObject extends object | ||
TKey extends keyof TObject, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -210,3 +211,3 @@ ? TObject extends object | ||
TKey extends keyof TObject, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = ValueOfKey<TObject, Exclude<keyof TObject, TKey>, TDistributeUnion>; | ||
@@ -219,3 +220,3 @@ | ||
TKey extends keyof TObject, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -230,3 +231,3 @@ ? TObject extends object | ||
TKey extends keyof TObject, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -243,3 +244,3 @@ ? TObject extends object | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -254,3 +255,3 @@ ? TObject extends object | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -265,3 +266,3 @@ ? TObject extends object | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -276,3 +277,3 @@ ? TObject extends object | ||
TValue, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = TDistributeUnion extends true | ||
@@ -288,7 +289,9 @@ ? TObject extends object | ||
TObject extends object, | ||
TDistributeUnion extends boolean = true | ||
TDistributeUnion extends boolean = true, | ||
> = Partial<KeepValueContainingType<TObject, undefined, TDistributeUnion>> & | ||
OmitValueContainingType<TObject, undefined, TDistributeUnion>; | ||
export type OptionalizeUndefinedDeep<T> = T extends object | ||
export type OptionalizeUndefinedDeep<T> = T extends Primitive | ||
? T | ||
: T extends object | ||
? { | ||
@@ -298,11 +301,24 @@ [K in KeyOfValueContainingType<T, undefined>]?: OptionalizeUndefinedDeep< | ||
>; | ||
} & | ||
{ | ||
[K in KeyOfValueNotContainingType< | ||
T, | ||
undefined | ||
>]: OptionalizeUndefinedDeep<T[K]>; | ||
} | ||
} & { | ||
[K in KeyOfValueNotContainingType< | ||
T, | ||
undefined | ||
>]: OptionalizeUndefinedDeep<T[K]>; | ||
} | ||
: T; | ||
// String | ||
type ReplaceString< | ||
T extends string, | ||
TSearch extends string, | ||
TReplace extends string, | ||
> = T extends `${infer TBefore}${TSearch}${infer TAfter}` | ||
? `${ReplaceString<TBefore, TSearch, TReplace>}${TReplace}${ReplaceString< | ||
TAfter, | ||
TSearch, | ||
TReplace | ||
>}` | ||
: T; | ||
// Miscellaneous | ||
@@ -314,5 +330,4 @@ | ||
export type PromiseType< | ||
TPromise extends Promise<any> | ||
> = TPromise extends Promise<infer T> ? T : never; | ||
export type PromiseType<TPromise extends Promise<any>> = | ||
TPromise extends Promise<infer T> ? T : never; | ||
@@ -334,11 +349,10 @@ export type DeepReadonly<T> = {readonly [P in keyof T]: DeepReadonly<T[P]>}; | ||
TObjectUnion extends object, | ||
TGeneralKey extends keyof TObjectUnion = keyof TObjectUnion | ||
> = {[TKey in TGeneralKey]: TObjectUnion[TKey]} & | ||
{ | ||
[TKey in __ObjectUnionNonGeneralKey<TObjectUnion>]?: TObjectUnion extends object | ||
? TKey extends keyof TObjectUnion | ||
? TObjectUnion[TKey] | ||
: never | ||
: never; | ||
}; | ||
TGeneralKey extends keyof TObjectUnion = keyof TObjectUnion, | ||
> = {[TKey in TGeneralKey]: TObjectUnion[TKey]} & { | ||
[TKey in __ObjectUnionNonGeneralKey<TObjectUnion>]?: TObjectUnion extends object | ||
? TKey extends keyof TObjectUnion | ||
? TObjectUnion[TKey] | ||
: never | ||
: never; | ||
}; | ||
@@ -351,5 +365,5 @@ export type Flatten<TUnion> = | ||
TObject extends object, | ||
TKey extends keyof TObject | ||
TKey extends keyof TObject, | ||
> = Omit<TObject, TKey> & Partial<Pick<TObject, TKey>>; | ||
export type DeepPartial<T> = {[P in keyof T]?: DeepPartial<T[P]>}; |
@@ -1,17 +0,17 @@ | ||
import {Primitive} from './types'; | ||
declare const __nominal_name: unique symbol; | ||
declare const __nominal_type: unique symbol; | ||
declare const __type: unique symbol; | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-definitions | ||
type __Type<T> = { | ||
[__type]: T; | ||
type __Type<TName, T> = { | ||
[__nominal_name]: TName; | ||
[__nominal_type]: T; | ||
}; | ||
export type Nominal<T, TName> = T & __Type<TName>; | ||
export type Nominal<T, TName> = T & __Type<TName, T>; | ||
export type Denominalize<T> = T extends Nominal<infer TDenominalized, any> | ||
export type Denominalize<T> = T extends __Type<any, infer TDenominalized> | ||
? TDenominalized | ||
: T; | ||
export type DenominalizeDeep<T> = T extends Nominal<infer TDenominalized, any> | ||
export type DenominalizeDeep<T> = T extends __Type<any, infer TDenominalized> | ||
? TDenominalized | ||
@@ -18,0 +18,0 @@ : {[TKey in keyof T]: DenominalizeDeep<T[TKey]>}; |
@@ -1,2 +0,9 @@ | ||
export type Primitive = undefined | null | boolean | string | number | symbol; | ||
export type Primitive = | ||
| undefined | ||
| null | ||
| boolean | ||
| string | ||
| number | ||
| bigint | ||
| symbol; | ||
@@ -3,0 +10,0 @@ export interface Dict<T> { |
{ | ||
"name": "tslang", | ||
"version": "0.1.23", | ||
"version": "0.1.24", | ||
"description": "TypeScript Language Type Utilities.", | ||
@@ -20,9 +20,9 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@mufan/code": "^0.2.5", | ||
"@mufan/eslint-plugin": "^0.1.37", | ||
"eslint": "^7.15.0", | ||
"prettier": "^2.2.1", | ||
"@mufan/code": "^0.2.9", | ||
"@mufan/eslint-plugin": "^0.1.42", | ||
"eslint": "^7.32.0", | ||
"prettier": "^2.4.1", | ||
"rimraf": "^3.0.2", | ||
"typescript": "^4.1.3" | ||
"typescript": "^4.4.4" | ||
} | ||
} |
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
13338
362