ts-type 2.1.10 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/index.js +0 -2
  3. package/lib/_build-in.d.ts +11 -10
  4. package/lib/_build-in.js.map +1 -1
  5. package/lib/generic.d.ts +2 -2
  6. package/lib/helper/array/readonly.d.ts +2 -2
  7. package/lib/helper/filter.d.ts +10 -10
  8. package/lib/helper/infer.d.ts +2 -2
  9. package/lib/helper/intersection.d.ts +1 -1
  10. package/lib/helper/key-value.d.ts +9 -5
  11. package/lib/helper/key-value.js.map +1 -1
  12. package/lib/helper/number.d.ts +4 -4
  13. package/lib/helper/overwrite.d.ts +1 -1
  14. package/lib/helper/promise.d.ts +3 -0
  15. package/lib/helper/{unpacked.js → promise.js} +1 -1
  16. package/lib/helper/promise.js.map +1 -0
  17. package/lib/helper/readonly.d.ts +10 -10
  18. package/lib/helper/readonly.js.map +1 -1
  19. package/lib/helper/record/enum.d.ts +7 -3
  20. package/lib/helper/record/enum.js.map +1 -1
  21. package/lib/helper/record/member.d.ts +2 -2
  22. package/lib/helper/record/omit-index.d.ts +7 -2
  23. package/lib/helper/record/omit-index.js.map +1 -1
  24. package/lib/helper/record/partial.d.ts +1 -1
  25. package/lib/helper/record/pick-one.d.ts +9 -0
  26. package/lib/{type/bluebird.js → helper/record/pick-one.js} +1 -4
  27. package/lib/helper/record/pick-one.js.map +1 -0
  28. package/lib/helper/record/pick-type.d.ts +16 -16
  29. package/lib/helper/record.d.ts +5 -5
  30. package/lib/helper/record.js.map +1 -1
  31. package/lib/helper/string/infer.d.ts +6 -0
  32. package/lib/helper/string/infer.js +3 -0
  33. package/lib/helper/string/infer.js.map +1 -0
  34. package/lib/helper/string/literal-string.d.ts +2 -2
  35. package/lib/helper/string.d.ts +5 -5
  36. package/lib/helper/tuple.d.ts +1 -1
  37. package/lib/helper/typeof.d.ts +2 -3
  38. package/lib/helper/typeof.js.map +1 -1
  39. package/lib/helper.d.ts +6 -8
  40. package/lib/helper.js.map +1 -1
  41. package/lib/index.d.ts +5 -2
  42. package/lib/index.js +0 -2
  43. package/lib/internal/logic/string-literal.d.ts +2 -2
  44. package/lib/logic/any.d.ts +2 -2
  45. package/lib/logic/any.js.map +1 -1
  46. package/lib/logic/never.d.ts +1 -1
  47. package/lib/logic/record/empty.d.ts +1 -1
  48. package/lib/logic/union/index.d.ts +15 -0
  49. package/lib/logic/union/index.js +3 -0
  50. package/lib/logic/union/index.js.map +1 -0
  51. package/lib/type/base.d.ts +9 -9
  52. package/lib/type/iterator.d.ts +2 -0
  53. package/lib/type/iterator.js +3 -0
  54. package/lib/type/iterator.js.map +1 -0
  55. package/lib/type/promise.d.ts +2 -2
  56. package/lib/type/proxy.d.ts +1 -1
  57. package/lib/type/record/empty.d.ts +2 -2
  58. package/lib/type/record/enum.d.ts +17 -1
  59. package/lib/type/record/enum.js.map +1 -1
  60. package/lib/type/record/partial.d.ts +2 -2
  61. package/lib/type/record/readonly.d.ts +4 -1
  62. package/lib/type/record/readonly.js.map +1 -1
  63. package/lib/type/record.d.ts +20 -20
  64. package/lib/type/record.js.map +1 -1
  65. package/lib/type/tuple/empty.d.ts +1 -1
  66. package/package.json +29 -11
  67. package/ts-toolbelt.js +0 -2
  68. package/lib/helper/unpacked.d.ts +0 -13
  69. package/lib/helper/unpacked.js.map +0 -1
  70. package/lib/type/bluebird.d.ts +0 -19
  71. package/lib/type/bluebird.js.map +0 -1
  72. package/tsconfig.check.json +0 -17
  73. package/tsconfig.check.tsbuildinfo +0 -1
  74. package/tsconfig.json.tpl +0 -3
  75. package/tsconfig.tsbuildinfo +0 -3148
package/CHANGELOG.md CHANGED
@@ -3,6 +3,45 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [3.0.1](https://github.com/bluelovers/ws-ts-type/compare/ts-type@2.1.10...ts-type@3.0.1) (2022-10-10)
7
+
8
+
9
+ ### BREAKING CHANGES
10
+
11
+ * remove `unpacked` , `bluebird`
12
+ * .
13
+
14
+
15
+
16
+ ### ✨ Features
17
+
18
+ * `ITSStringInferToType` ([cbc1788](https://github.com/bluelovers/ws-ts-type/commit/cbc1788d087a320d2dd837c42cd353d3a43a34f3))
19
+ * ITSPickOne ([4f056cd](https://github.com/bluelovers/ws-ts-type/commit/4f056cdf4078ac06adea3c82bd000229714039d2))
20
+ * remove `unpacked` , `bluebird` ([52247d9](https://github.com/bluelovers/ws-ts-type/commit/52247d98ca482f5d0dfe879d3c6d69936dcfa195))
21
+
22
+
23
+ ### 📦 Code Refactoring
24
+
25
+ * . ([b656466](https://github.com/bluelovers/ws-ts-type/commit/b656466b216e331293acb9c77b36054cb0bd0c2b))
26
+
27
+
28
+ ### 🛠 Build System
29
+
30
+ * update typescript ([eb59d89](https://github.com/bluelovers/ws-ts-type/commit/eb59d897c2888c7a45406ffcad4b9033608b0b66))
31
+
32
+
33
+ ### 📌 Dependencies
34
+
35
+ * update deps ([ab5f3e4](https://github.com/bluelovers/ws-ts-type/commit/ab5f3e48da1f10ddd4445ba6dda9a0a68c5f656f))
36
+
37
+
38
+ ### 🔖 Miscellaneous
39
+
40
+ * . ([6588a93](https://github.com/bluelovers/ws-ts-type/commit/6588a932156f6e44e746b3ae2452336a04833153))
41
+ * . ([4eddd02](https://github.com/bluelovers/ws-ts-type/commit/4eddd023316693edd41fda4e2c6338bc507775a6))
42
+
43
+
44
+
6
45
  ## [2.1.10](https://github.com/bluelovers/ws-ts-type/compare/ts-type@2.1.9...ts-type@2.1.10) (2022-08-10)
7
46
 
8
47
 
package/index.js CHANGED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,16 +2,17 @@
2
2
  * re-export build-in type
3
3
  * for some time ide is stupid can't found types
4
4
  */
5
- export declare type ITSParameters<T extends (...args: any[]) => any> = Parameters<T>;
6
- export declare type ITSConstructorParameters<T extends new (...args: any[]) => any> = ConstructorParameters<T>;
7
- export declare type ITSPartial<T> = Partial<T>;
8
- export declare type ITSPick<T, K extends keyof T> = Pick<T, K>;
9
- export declare type ITSInstanceType<T extends new (...args: any[]) => any> = InstanceType<T>;
10
- export declare type ITSClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
11
- export declare type ITSPropertyDecorator = (target: object, propertyKey: string | symbol) => void;
12
- export declare type ITSMethodDecorator = <T>(target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
13
- export declare type ITSParameterDecorator = (target: object, propertyKey: string | symbol, parameterIndex: number) => void;
5
+ export type ITSParameters<T extends (...args: any[]) => any> = Parameters<T>;
6
+ export type ITSConstructorParameters<T extends new (...args: any[]) => any> = ConstructorParameters<T>;
7
+ export type ITSPartial<T> = Partial<T>;
8
+ export type ITSPick<T, K extends keyof T = keyof T> = Pick<T, K>;
9
+ export type ITSInstanceType<T extends new (...args: any[]) => any> = InstanceType<T>;
10
+ export type ITSClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;
11
+ export type ITSPropertyDecorator = (target: object, propertyKey: string | symbol) => void;
12
+ export type ITSMethodDecorator = <T>(target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;
13
+ export type ITSParameterDecorator = (target: object, propertyKey: string | symbol, parameterIndex: number) => void;
14
14
  /**
15
15
  * Exclude null and undefined from T
16
+ * @see https://devblogs.microsoft.com/typescript/announcing-typescript-4-8/#improved-intersection-reduction-union-compatibility-and-narrowing
16
17
  */
17
- export declare type ITSNonNullable<T> = T extends null | undefined ? never : T;
18
+ export type ITSNonNullable<T> = NonNullable<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"_build-in.js","sourceRoot":"","sources":["_build-in.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * re-export build-in type\n * for some time ide is stupid can't found types\n */\n\nexport type ITSParameters<T extends (...args: any[]) => any> = Parameters<T>\nexport type ITSConstructorParameters<T extends new (...args: any[]) => any> = ConstructorParameters<T>\nexport type ITSPartial<T> = Partial<T>\nexport type ITSPick<T, K extends keyof T> = Pick<T, K>\nexport type ITSInstanceType<T extends new (...args: any[]) => any> = InstanceType<T>\n\n\nexport type ITSClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;\nexport type ITSPropertyDecorator = (target: object, propertyKey: string | symbol) => void;\nexport type ITSMethodDecorator = <T>(target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;\nexport type ITSParameterDecorator = (target: object, propertyKey: string | symbol, parameterIndex: number) => void;\n\n/**\n * Exclude null and undefined from T\n */\nexport type ITSNonNullable<T> = T extends null | undefined ? never : T;\n"]}
1
+ {"version":3,"file":"_build-in.js","sourceRoot":"","sources":["_build-in.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * re-export build-in type\n * for some time ide is stupid can't found types\n */\n\nexport type ITSParameters<T extends (...args: any[]) => any> = Parameters<T>\nexport type ITSConstructorParameters<T extends new (...args: any[]) => any> = ConstructorParameters<T>\nexport type ITSPartial<T> = Partial<T>\nexport type ITSPick<T, K extends keyof T = keyof T> = Pick<T, K>\nexport type ITSInstanceType<T extends new (...args: any[]) => any> = InstanceType<T>\n\n\nexport type ITSClassDecorator = <TFunction extends Function>(target: TFunction) => TFunction | void;\nexport type ITSPropertyDecorator = (target: object, propertyKey: string | symbol) => void;\nexport type ITSMethodDecorator = <T>(target: object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T> | void;\nexport type ITSParameterDecorator = (target: object, propertyKey: string | symbol, parameterIndex: number) => void;\n\n/**\n * Exclude null and undefined from T\n * @see https://devblogs.microsoft.com/typescript/announcing-typescript-4-8/#improved-intersection-reduction-union-compatibility-and-narrowing\n */\nexport type ITSNonNullable<T> = NonNullable<T>;\n"]}
package/lib/generic.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare type ITSTypeFunction<T> = (...args: any[]) => T;
1
+ export type ITSTypeFunction<T> = (...args: any[]) => T;
2
2
  export interface ITSMapLike<K, V> {
3
3
  get(key: K): V | undefined;
4
4
  has(key: K): boolean;
@@ -9,7 +9,7 @@ export interface ITSSetLike<V> {
9
9
  /**
10
10
  * @see bluebird
11
11
  */
12
- export declare type ITSResolvable<R> = R | PromiseLike<R>;
12
+ export type ITSResolvable<R> = R | PromiseLike<R>;
13
13
  export interface ITSArrayLikeWriteable<T> {
14
14
  readonly length: number;
15
15
  [n: number]: T;
@@ -1,3 +1,3 @@
1
1
  import { ITSArrayListMaybeReadonly } from '../../type/base';
2
- export declare type ITSToReadonlyArray<T extends ITSArrayListMaybeReadonly<any>> = T extends [...infer R] | readonly [...infer R] ? readonly [...R] : never;
3
- export declare type ITSToWriteableArray<T extends ITSArrayListMaybeReadonly<any>> = T extends [...infer R] | readonly [...infer R] ? [...R] : never;
2
+ export type ITSToReadonlyArray<T extends ITSArrayListMaybeReadonly<any>> = T extends [...infer R] | readonly [...infer R] ? readonly [...R] : never;
3
+ export type ITSToWriteableArray<T extends ITSArrayListMaybeReadonly<any>> = T extends [...infer R] | readonly [...infer R] ? [...R] : never;
@@ -4,30 +4,30 @@
4
4
  /**
5
5
  * Exclude from T those types that are assignable to U, and replace to R
6
6
  */
7
- export declare type ITSExclude2<T, U, R = T> = T extends U ? never : R;
7
+ export type ITSExclude2<T, U, R = T> = T extends U ? never : R;
8
8
  /**
9
9
  * Extract from T those types that are assignable to U, and replace to R
10
10
  */
11
- export declare type ITSExtract2<T, U, R = T> = T extends U ? R : never;
12
- export declare type ITSExtractKeyof<T, U> = Extract<keyof T, U>;
13
- export declare type ITSExtractArrayLike<A, K extends Extract<keyof A, number> = Extract<keyof A, number>> = {
11
+ export type ITSExtract2<T, U, R = T> = T extends U ? R : never;
12
+ export type ITSExtractKeyof<T, U> = Extract<keyof T, U>;
13
+ export type ITSExtractArrayLike<A, K extends Extract<keyof A, number> = Extract<keyof A, number>> = {
14
14
  [Index in K]: A[Index];
15
15
  };
16
- export declare type ITSKeyofArrayLike<A> = keyof ITSExtractArrayLike<A>;
17
- export declare type ITSNullable<T> = T extends null | undefined ? T : never;
16
+ export type ITSKeyofArrayLike<A> = keyof ITSExtractArrayLike<A>;
17
+ export type ITSNullable<T> = T extends null | undefined ? T : never;
18
18
  /**
19
19
  * 找出 T 當中 與 U 相同的 key
20
20
  */
21
- export declare type ITSKeyofSame<T, U> = Extract<keyof T, keyof U>;
21
+ export type ITSKeyofSame<T, U> = Extract<keyof T, keyof U>;
22
22
  /**
23
23
  * 找出 T 當中 與 U 不同的 key
24
24
  */
25
- export declare type ITSKeyofDiff<T, U> = Exclude<keyof T, ITSKeyofSame<T, U>>;
25
+ export type ITSKeyofDiff<T, U> = Exclude<keyof T, ITSKeyofSame<T, U>>;
26
26
  /**
27
27
  * 找出 T 與 U 當中同時存在的 key
28
28
  */
29
- export declare type ITSKeyofBothSame<T, U> = ITSKeyofSame<T, U> | ITSKeyofSame<U, T>;
29
+ export type ITSKeyofBothSame<T, U> = ITSKeyofSame<T, U> | ITSKeyofSame<U, T>;
30
30
  /**
31
31
  * 去除 T 與 U 當中同時存在的 key
32
32
  */
33
- export declare type ITSKeyofBothDiff<T, U> = ITSKeyofDiff<T, U> | ITSKeyofDiff<U, T>;
33
+ export type ITSKeyofBothDiff<T, U> = ITSKeyofDiff<T, U> | ITSKeyofDiff<U, T>;
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * Created by user on 2019/6/12.
3
3
  */
4
- export declare type ITSValueOfMember<T, K extends keyof T> = T extends {
4
+ export type ITSValueOfMember<T, K extends keyof T> = T extends {
5
5
  [p in K]: infer U;
6
6
  } ? U : never;
7
- export declare type ITSLengthOf<T extends {
7
+ export type ITSLengthOf<T extends {
8
8
  length: number;
9
9
  }> = ITSValueOfMember<T, 'length'>;
@@ -6,4 +6,4 @@
6
6
  * type SynthesizedFunctionIntersection = ITSUnionToIntersection<FunctionUnion>
7
7
  * // type SynthesizedFunctionIntersection = (() => void) & ((p: string) => void)
8
8
  */
9
- export declare type ITSUnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
9
+ export type ITSUnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
@@ -6,8 +6,12 @@
6
6
  */
7
7
  import { ITSMapLike } from '../generic';
8
8
  import { ITSIteratorLazy } from './typeof';
9
- export declare type ITSValueOf<T> = T[keyof T];
10
- export declare type ITSKeyOf<T> = keyof T;
11
- export declare type ITSPickValueOf<T, K extends keyof T> = ITSValueOf<Pick<T, K>>;
12
- export declare type ITSValueOfIterator<T extends ITSIteratorLazy<any>> = (T extends Iterator<infer U> ? U : T extends IteratorResult<infer U> ? U : any)[];
13
- export declare type ITSValueOfMap<T extends ITSMapLike<any, any>> = T extends ITSMapLike<any, infer U> ? U[] : any[];
9
+ import { ITSArrayListMaybeReadonly } from '../type/base';
10
+ export type ITSValueOf<T extends Record<any, any>> = T[keyof T];
11
+ export type { ITSValueOf as ITSValueOfRecord };
12
+ export type ITSKeyOf<T> = keyof T;
13
+ export type ITSPickValueOf<T, K extends keyof T> = ITSValueOf<Pick<T, K>>;
14
+ export type ITSValueOfIterator<T extends ITSIteratorLazy<any>> = (T extends Iterator<infer U> ? U : T extends IteratorResult<infer U> ? U : any)[];
15
+ export type ITSValueOfMap<T extends ITSMapLike<any, any>> = T extends ITSMapLike<any, infer U> ? U[] : any[];
16
+ export type ITSValueOfArray<T extends ITSArrayListMaybeReadonly<any>> = T extends readonly (infer U)[] ? U : T extends (infer U)[] ? U : never;
17
+ export type ITSValueOfArrayLike<T extends ITSArrayListMaybeReadonly<any> | ArrayLike<any>> = T extends ITSArrayListMaybeReadonly<T> ? ITSValueOfArray<T> : T extends ArrayLike<infer U> ? U : never;
@@ -1 +1 @@
1
- {"version":3,"file":"key-value.js","sourceRoot":"","sources":["key-value.ts"],"names":[],"mappings":";AAAA;;GAEG","sourcesContent":["/**\n * Created by user on 2019/6/11.\n */\n\n/**\n * https://stackoverflow.com/questions/49285864/is-there-a-valueof-similar-to-keyof-in-typescript\n */\nimport { ITSMapLike } from '../generic';\nimport { ITSIteratorLazy } from './typeof';\n\nexport type ITSValueOf<T> = T[keyof T];\nexport type ITSKeyOf<T> = keyof T;\n\nexport type ITSPickValueOf<T, K extends keyof T> = ITSValueOf<Pick<T, K>>;\n\nexport type ITSValueOfIterator<T extends ITSIteratorLazy<any>> =\n\t(T extends Iterator<infer U> ? U :\n\t\tT extends IteratorResult<infer U> ? U :\n\t\t\tany)[]\n\t;\n\nexport type ITSValueOfMap<T extends ITSMapLike<any, any>> =\n\tT extends ITSMapLike<any, infer U> ? U[] :\n\t\tany[]\n\t;\n\n\n"]}
1
+ {"version":3,"file":"key-value.js","sourceRoot":"","sources":["key-value.ts"],"names":[],"mappings":";AAAA;;GAEG","sourcesContent":["/**\n * Created by user on 2019/6/11.\n */\n\n/**\n * https://stackoverflow.com/questions/49285864/is-there-a-valueof-similar-to-keyof-in-typescript\n */\nimport { ITSMapLike } from '../generic';\nimport { ITSIteratorLazy } from './typeof';\nimport { ITSArrayListMaybeReadonly } from '../type/base';\n\nexport type ITSValueOf<T extends Record<any, any>> = T[keyof T];\n\nexport type { ITSValueOf as ITSValueOfRecord };\n\nexport type ITSKeyOf<T> = keyof T;\n\nexport type ITSPickValueOf<T, K extends keyof T> = ITSValueOf<Pick<T, K>>;\n\nexport type ITSValueOfIterator<T extends ITSIteratorLazy<any>> =\n\t(T extends Iterator<infer U> ? U :\n\t\tT extends IteratorResult<infer U> ? U :\n\t\t\tany)[]\n\t;\n\nexport type ITSValueOfMap<T extends ITSMapLike<any, any>> =\n\tT extends ITSMapLike<any, infer U> ? U[] :\n\t\tany[]\n\t;\n\nexport type ITSValueOfArray<T extends ITSArrayListMaybeReadonly<any>> =\n\tT extends readonly (infer U)[]\n\t\t? U : T extends (infer U)[]\n\t\t\t\t? U : never\n\t;\n\nexport type ITSValueOfArrayLike<T extends ITSArrayListMaybeReadonly<any> | ArrayLike<any>> =\n\tT extends ITSArrayListMaybeReadonly<T>\n\t\t? ITSValueOfArray<T> : T extends ArrayLike<infer U>\n\t\t\t? U : never\n\t;\n"]}
@@ -1,5 +1,5 @@
1
1
  import { ITSToStringLiteral } from './string';
2
- export declare type ITSNumberString<N extends number | bigint = number> = ITSToStringLiteral<N>;
3
- export declare type ITSUnpackNumberString<S extends string, R = never> = S extends ITSNumberString<infer N> ? N : R;
4
- export declare type ITSNumberValue = number | string;
5
- export declare type ITSNumberValue2 = number | ITSNumberString;
2
+ export type ITSNumberString<N extends number | bigint = number> = ITSToStringLiteral<N>;
3
+ export type ITSUnpackNumberString<S extends string, R = never> = S extends ITSNumberString<infer N> ? N : R;
4
+ export type ITSNumberValue = number | string;
5
+ export type ITSNumberValue2 = number | ITSNumberString;
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * Created by user on 2019/6/11.
3
3
  */
4
- export declare type ITSOverwriteThisFunction<T extends any, F extends (...args: any[]) => any> = (this: T, ...args: Parameters<F>) => ReturnType<F>;
4
+ export type ITSOverwriteThisFunction<T extends any, F extends (...args: any[]) => any> = (this: T, ...args: Parameters<F>) => ReturnType<F>;
@@ -0,0 +1,3 @@
1
+ import { ITSAnyFunction } from '../type/base';
2
+ export type ITSAwaitedLazy<T> = T extends PromiseLike<infer U> ? Awaited<U> : T;
3
+ export type ITSAwaitedReturnType<T extends ITSAnyFunction> = ITSAwaitedLazy<ReturnType<T>>;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=unpacked.js.map
3
+ //# sourceMappingURL=promise.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"promise.js","sourceRoot":"","sources":["promise.ts"],"names":[],"mappings":"","sourcesContent":["import { ITSAnyFunction } from '../type/base';\n\nexport type ITSAwaitedLazy<T> = T extends PromiseLike<infer U> ? Awaited<U> : T;\n\nexport type ITSAwaitedReturnType<T extends ITSAnyFunction> = ITSAwaitedLazy<ReturnType<T>>\n"]}
@@ -1,27 +1,27 @@
1
+ import { ITSValueOfArray } from './key-value';
1
2
  /**
2
3
  * @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html
3
4
  *
4
5
  * Add readonly and ?
5
6
  */
6
- import { ITSUnpackedArrayLike } from './unpacked';
7
- export declare type ITSReadonlyPartial<T> = {
7
+ export type ITSReadonlyPartial<T> = {
8
8
  readonly [P in keyof T]?: T[P];
9
9
  };
10
- export declare type ITSWriteable<T> = ITSWriteablePick<T, keyof T>;
11
- export declare type ITSWriteablePick<T, K extends keyof T = keyof T> = {
10
+ export type ITSWriteable<T> = ITSWriteablePick<T, keyof T>;
11
+ export type ITSWriteablePick<T, K extends keyof T = keyof T> = {
12
12
  -readonly [P in K]: T[P];
13
13
  };
14
- export declare type ITSReadonlyPick<T, K extends keyof T = keyof T> = {
14
+ export type ITSReadonlyPick<T, K extends keyof T = keyof T> = {
15
15
  readonly [P in K]: T[P];
16
16
  };
17
- export declare type ITSWriteableWith<T, K extends keyof T = keyof T> = Omit<T, K> & ITSWriteablePick<T, K>;
18
- export declare type ITSReadonlyWith<T, K extends keyof T = keyof T> = Omit<T, K> & ITSReadonlyPick<T, K>;
19
- export declare type ITSReadonlyToWriteableArray<T extends readonly any[]> = Omit<T, keyof any[]> & ITSUnpackedArrayLike<T>[] & {
17
+ export type ITSWriteableWith<T, K extends keyof T = keyof T> = Omit<T, K> & ITSWriteablePick<T, K>;
18
+ export type ITSReadonlyWith<T, K extends keyof T = keyof T> = Omit<T, K> & ITSReadonlyPick<T, K>;
19
+ export type ITSReadonlyToWriteableArray<T extends readonly any[]> = Omit<T, keyof any[]> & ITSValueOfArray<T>[] & {
20
20
  -readonly [P in number | 'length']: T[P];
21
21
  };
22
- export declare type ITSWriteableDeep<T, K extends keyof T = keyof T> = T extends Record<any, any> ? {
22
+ export type ITSWriteableDeep<T, K extends keyof T = keyof T> = T extends Record<any, any> ? {
23
23
  -readonly [P in K]: ITSWriteableDeep<T[P]>;
24
24
  } : T;
25
- export declare type ITSReadonlyDeep<T, K extends keyof T = keyof T> = T extends Record<any, any> ? {
25
+ export type ITSReadonlyDeep<T, K extends keyof T = keyof T> = T extends Record<any, any> ? {
26
26
  readonly [P in K]: ITSReadonlyDeep<T[P]>;
27
27
  } : T;
@@ -1 +1 @@
1
- {"version":3,"file":"readonly.js","sourceRoot":"","sources":["readonly.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html\n *\n * Add readonly and ?\n */\nimport { ITSUnpackedArrayLike } from './unpacked';\n\nexport type ITSReadonlyPartial<T> = {\n\treadonly [P in keyof T]?: T[P]\n};\n\nexport type ITSWriteable<T> = ITSWriteablePick<T, keyof T>;\n\nexport type ITSWriteablePick<T, K extends keyof T = keyof T> = {\n\t-readonly [P in K]: T[P];\n};\n\nexport type ITSReadonlyPick<T, K extends keyof T = keyof T> = {\n\treadonly [P in K]: T[P];\n};\n\nexport type ITSWriteableWith<T, K extends keyof T = keyof T> = Omit<T, K> & ITSWriteablePick<T, K>;\n\nexport type ITSReadonlyWith<T, K extends keyof T = keyof T> = Omit<T, K> & ITSReadonlyPick<T, K>;\n\nexport type ITSReadonlyToWriteableArray<T extends readonly any[]> = Omit<T, keyof any[]> & ITSUnpackedArrayLike<T>[] & {\n\t-readonly [P in number | 'length']: T[P]\n};\n\nexport type ITSWriteableDeep<T, K extends keyof T = keyof T> = T extends Record<any, any> ? {\n\t-readonly [P in K]: ITSWriteableDeep<T[P]>;\n} : T;\n\nexport type ITSReadonlyDeep<T, K extends keyof T = keyof T> =\n\tT extends Record<any, any> ? {\n\treadonly [P in K]: ITSReadonlyDeep<T[P]>;\n} : T;\n"]}
1
+ {"version":3,"file":"readonly.js","sourceRoot":"","sources":["readonly.ts"],"names":[],"mappings":"","sourcesContent":["\nimport { ITSValueOfArray } from './key-value';\n\n/**\n * @see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html\n *\n * Add readonly and ?\n */\nexport type ITSReadonlyPartial<T> = {\n\treadonly [P in keyof T]?: T[P]\n};\n\nexport type ITSWriteable<T> = ITSWriteablePick<T, keyof T>;\n\nexport type ITSWriteablePick<T, K extends keyof T = keyof T> = {\n\t-readonly [P in K]: T[P];\n};\n\nexport type ITSReadonlyPick<T, K extends keyof T = keyof T> = {\n\treadonly [P in K]: T[P];\n};\n\nexport type ITSWriteableWith<T, K extends keyof T = keyof T> = Omit<T, K> & ITSWriteablePick<T, K>;\n\nexport type ITSReadonlyWith<T, K extends keyof T = keyof T> = Omit<T, K> & ITSReadonlyPick<T, K>;\n\nexport type ITSReadonlyToWriteableArray<T extends readonly any[]> = Omit<T, keyof any[]> & ITSValueOfArray<T>[] & {\n\t-readonly [P in number | 'length']: T[P]\n};\n\nexport type ITSWriteableDeep<T, K extends keyof T = keyof T> = T extends Record<any, any> ? {\n\t-readonly [P in K]: ITSWriteableDeep<T[P]>;\n} : T;\n\nexport type ITSReadonlyDeep<T, K extends keyof T = keyof T> =\n\tT extends Record<any, any> ? {\n\treadonly [P in K]: ITSReadonlyDeep<T[P]>;\n} : T;\n"]}
@@ -1,4 +1,8 @@
1
1
  import { ITSEnumLike } from '../../type/record/enum';
2
- import { ITSValueOfRecord } from '../../helper';
3
- export declare type ITSExcludeEnumValue<Enum extends ITSEnumLike, U extends ITSValueOfRecord<Enum>> = Exclude<ITSValueOfRecord<Enum>, U>;
4
- export declare type ITSExtractEnumValue<Enum extends ITSEnumLike, U extends ITSValueOfRecord<Enum>> = Extract<ITSValueOfRecord<Enum>, U>;
2
+ import { ITSValueOf } from '../key-value';
3
+ import { ITSStringInferToNumber } from '../string/infer';
4
+ import { ITSToStringLiteral } from '../string';
5
+ export type ITSExcludeEnumValue<Enum extends ITSEnumLike, U extends ITSValueOf<Enum>> = Exclude<ITSValueOf<Enum>, U>;
6
+ export type ITSExtractEnumValue<Enum extends ITSEnumLike, U extends ITSValueOf<Enum>> = Extract<ITSValueOf<Enum>, U>;
7
+ export type ITSNumberEnumToNumber<T extends number> = ITSStringInferToNumber<ITSToStringLiteral<Extract<T, number>>>;
8
+ export type ITSNumberEnumAndNumber<T extends number> = Extract<T, number> | ITSNumberEnumToNumber<T>;
@@ -1 +1 @@
1
- {"version":3,"file":"enum.js","sourceRoot":"","sources":["enum.ts"],"names":[],"mappings":"","sourcesContent":["import { ITSEnumLike } from '../../type/record/enum';\nimport { ITSValueOfRecord } from '../../helper';\n\nexport type ITSExcludeEnumValue<Enum extends ITSEnumLike, U extends ITSValueOfRecord<Enum>> = Exclude<ITSValueOfRecord<Enum>, U>;\n\nexport type ITSExtractEnumValue<Enum extends ITSEnumLike, U extends ITSValueOfRecord<Enum>> = Extract<ITSValueOfRecord<Enum>, U>;\n"]}
1
+ {"version":3,"file":"enum.js","sourceRoot":"","sources":["enum.ts"],"names":[],"mappings":"","sourcesContent":["import { ITSEnumLike, ITSNumberEnumLike } from '../../type/record/enum';\nimport { ITSValueOf } from '../key-value';\nimport { ITSStringInferToNumber } from '../string/infer';\nimport { ITSToStringLiteral } from '../string';\n\nexport type ITSExcludeEnumValue<Enum extends ITSEnumLike, U extends ITSValueOf<Enum>> = Exclude<ITSValueOf<Enum>, U>;\n\nexport type ITSExtractEnumValue<Enum extends ITSEnumLike, U extends ITSValueOf<Enum>> = Extract<ITSValueOf<Enum>, U>;\n\nexport type ITSNumberEnumToNumber<T extends number> = ITSStringInferToNumber<ITSToStringLiteral<Extract<T, number>>>\n\nexport type ITSNumberEnumAndNumber<T extends number> = Extract<T, number> | ITSNumberEnumToNumber<T>\n"]}
@@ -4,5 +4,5 @@ import { ITSExtractKeyof } from '../filter';
4
4
  /**
5
5
  * filter all member is function and key type is string or symbol
6
6
  */
7
- export declare type ITSMemberMethods<T> = ITSExtractRecord<T, Function, Extract<keyof T, ITSPropertyKey>>;
8
- export declare type ITSKeyofMemberMethods<T> = ITSExtractKeyof<ITSMemberMethods<T>, ITSPropertyKey>;
7
+ export type ITSMemberMethods<T> = ITSExtractRecord<T, Function, Extract<keyof T, ITSPropertyKey>>;
8
+ export type ITSKeyofMemberMethods<T> = ITSExtractKeyof<ITSMemberMethods<T>, ITSPropertyKey>;
@@ -3,7 +3,12 @@
3
3
  *
4
4
  * @see https://stackoverflow.com/a/51956054/4563339
5
5
  */
6
- export declare type ITSOmitIndexSignatures<T> = {
6
+ export type ITSOmitIndexSignatures<T extends Record<any, any>> = {
7
7
  [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
8
8
  };
9
- export declare type ITSKnownKeys<T> = keyof ITSOmitIndexSignatures<T>;
9
+ export type ITSKnownKeys<T extends Record<any, any>> = keyof ITSOmitIndexSignatures<T>;
10
+ export type ITSKnownKeys2<T> = {
11
+ [K in keyof T]: string extends K ? never : number extends K ? never : K;
12
+ } extends {
13
+ [_ in keyof T]: infer U;
14
+ } ? U : never;
@@ -1 +1 @@
1
- {"version":3,"file":"omit-index.js","sourceRoot":"","sources":["omit-index.ts"],"names":[],"mappings":";AAAA,EAAE","sourcesContent":["//\n\n/**\n * remove index signature using mapped types\n *\n * @see https://stackoverflow.com/a/51956054/4563339\n */\nexport type ITSOmitIndexSignatures<T> = {\n\t[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]\n};\n\nexport type ITSKnownKeys<T> = keyof ITSOmitIndexSignatures<T>;\n"]}
1
+ {"version":3,"file":"omit-index.js","sourceRoot":"","sources":["omit-index.ts"],"names":[],"mappings":";AAAA,EAAE","sourcesContent":["//\n\n/**\n * remove index signature using mapped types\n *\n * @see https://stackoverflow.com/a/51956054/4563339\n */\nexport type ITSOmitIndexSignatures<T extends Record<any, any>> = {\n\t[K in keyof T as string extends K ? never : number extends K ? never : K]: T[K]\n};\n\nexport type ITSKnownKeys<T extends Record<any, any>> = keyof ITSOmitIndexSignatures<T>;\n\nexport type ITSKnownKeys2<T> = {\n\t[K in keyof T]: string extends K ? never : number extends K ? never : K\n} extends { [_ in keyof T]: infer U } ? U : never;\n"]}
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * try check key is partial of record
3
3
  */
4
- export declare type ITSKeyIsPartialOfRecord<T, K extends keyof T> = Omit<T, K> extends T ? K : never;
4
+ export type ITSKeyIsPartialOfRecord<T, K extends keyof T> = Omit<T, K> extends T ? K : never;
@@ -0,0 +1,9 @@
1
+ import { ITSPartialRecord } from '../../type/record/partial';
2
+ /**
3
+ * 在项目开发中,很多时候会遇到一种场景,需要定义一个对象的类型,此类型必须包含某n个字段中的其中一种,且只选一个。
4
+ *
5
+ * @see https://juejin.cn/post/7150316226009382919#heading-2
6
+ */
7
+ export type ITSPickOne<T, Keys extends keyof T = keyof T> = {
8
+ [K in Keys]: Record<K, T[K]> & ITSPartialRecord<Exclude<keyof T, K>, void>;
9
+ }[Keys];
@@ -1,6 +1,3 @@
1
1
  "use strict";
2
- /**
3
- * Created by user on 2019/5/17.
4
- */
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- //# sourceMappingURL=bluebird.js.map
3
+ //# sourceMappingURL=pick-one.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pick-one.js","sourceRoot":"","sources":["pick-one.ts"],"names":[],"mappings":"","sourcesContent":["import { ITSPartialRecord } from '../../type/record/partial';\n\n/**\n * 在项目开发中,很多时候会遇到一种场景,需要定义一个对象的类型,此类型必须包含某n个字段中的其中一种,且只选一个。\n *\n * @see https://juejin.cn/post/7150316226009382919#heading-2\n */\nexport type ITSPickOne<T, Keys extends keyof T = keyof T> = {\n\t[K in Keys]: Record<K, T[K]> & ITSPartialRecord<Exclude<keyof T, K>, void>\n}[Keys]\n"]}
@@ -5,12 +5,12 @@
5
5
  import { ITSNullPrimitive } from '../../type/base';
6
6
  import { ITSValueOf } from '../key-value';
7
7
  import { ITSExclude2, ITSExtract2 } from '../filter';
8
- export declare type ITSKeyofByExtractType<T extends Record<keyof any, any>, U, K extends keyof T = keyof T> = K extends keyof T ? T[K] extends U ? K : never : never;
8
+ export type ITSKeyofByExtractType<T extends Record<keyof any, any>, U, K extends keyof T = keyof T> = K extends keyof T ? T[K] extends U ? K : never : never;
9
9
  /**
10
10
  * @see https://github.com/type-challenges/type-challenges/blob/master/questions/2595-medium-pickbytype/README.md
11
11
  * @see https://github.com/type-challenges/type-challenges/issues/3814
12
12
  */
13
- export declare type ITSKeyofByExcludeType<T extends Record<keyof any, any>, U, K extends keyof T = keyof T> = K extends keyof T ? T[K] extends U ? never : K : never;
13
+ export type ITSKeyofByExcludeType<T extends Record<keyof any, any>, U, K extends keyof T = keyof T> = K extends keyof T ? T[K] extends U ? never : K : never;
14
14
  /**
15
15
  * From `T`, pick a set of properties whose type are assignable to `U`.
16
16
  *
@@ -25,7 +25,7 @@ type OmitBoolean = ITSPickByType<{
25
25
  * @see https://github.com/type-challenges/type-challenges/blob/master/questions/2595-medium-pickbytype/README.md
26
26
  * @see https://github.com/type-challenges/type-challenges/issues/3814
27
27
  */
28
- export declare type ITSPickByType<T extends Record<keyof any, any>, U, K extends keyof T = keyof T> = {
28
+ export type ITSPickByType<T extends Record<keyof any, any>, U, K extends keyof T = keyof T> = {
29
29
  [P in ITSKeyofByExtractType<T, U, K>]: T[P];
30
30
  };
31
31
  /**
@@ -42,42 +42,42 @@ type OmitBoolean = ITSOmitByType<{
42
42
  * @see https://github.com/type-challenges/type-challenges/blob/master/questions/2595-medium-pickbytype/README.md
43
43
  * @see https://github.com/type-challenges/type-challenges/issues/3814
44
44
  */
45
- export declare type ITSOmitByType<T extends Record<keyof any, any>, U, K extends keyof T = keyof T> = {
45
+ export type ITSOmitByType<T extends Record<keyof any, any>, U, K extends keyof T = keyof T> = {
46
46
  [P in ITSKeyofByExcludeType<T, U, K>]: T[P];
47
47
  };
48
48
  /**
49
49
  * @internal
50
50
  */
51
- export declare type ITSRecordExcludeToKey<Base, Type> = {
51
+ export type ITSRecordExcludeToKey<Base, Type> = {
52
52
  [Key in keyof Base]: ITSExclude2<Base[Key], Type, Key>;
53
53
  };
54
54
  /**
55
55
  * @internal
56
56
  */
57
- export declare type ITSRecordExtractToKey<Base, Type> = {
57
+ export type ITSRecordExtractToKey<Base, Type> = {
58
58
  [Key in keyof Base]: ITSExtract2<Base[Key], Type, Key>;
59
59
  };
60
- export declare type ITSKeyOfRecordExcludeToKey<Base, Type> = ITSValueOf<ITSRecordExcludeToKey<Base, Type>>;
61
- export declare type ITSKeyOfRecordExtractToKey<Base, Type> = ITSValueOf<ITSRecordExtractToKey<Base, Type>>;
62
- export declare type ITSPickRecordType<Base, Type> = Pick<Base, ITSKeyOfRecordExtractToKey<Base, Type>>;
63
- export declare type ITSOmitRecordType<Base, Type> = Pick<Base, ITSKeyOfRecordExcludeToKey<Base, Type>>;
60
+ export type ITSKeyOfRecordExcludeToKey<Base, Type> = ITSValueOf<ITSRecordExcludeToKey<Base, Type>>;
61
+ export type ITSKeyOfRecordExtractToKey<Base, Type> = ITSValueOf<ITSRecordExtractToKey<Base, Type>>;
62
+ export type ITSPickRecordType<Base, Type> = Pick<Base, ITSKeyOfRecordExtractToKey<Base, Type>>;
63
+ export type ITSOmitRecordType<Base, Type> = Pick<Base, ITSKeyOfRecordExcludeToKey<Base, Type>>;
64
64
  /**
65
65
  * @deprecated use `ITSPickByType<M, T, K>`
66
66
  */
67
- export declare type ITSExtractRecord<M, T, K extends keyof M = keyof M> = ITSPickByType<M, T, K>;
68
- export declare type ITSExtractRecordNoNull<M, T, K extends keyof M = keyof M> = {
67
+ export type ITSExtractRecord<M, T, K extends keyof M = keyof M> = ITSPickByType<M, T, K>;
68
+ export type ITSExtractRecordNoNull<M, T, K extends keyof M = keyof M> = {
69
69
  [P in K]: NonNullable<M[P]>;
70
70
  };
71
71
  /**
72
72
  * @deprecated use `ITSOmitByType<M, T, K>`
73
73
  */
74
- export declare type ITSExcludeRecord<M, T, K extends keyof M = keyof M> = ITSOmitByType<M, T, K>;
75
- export declare type ITSExcludeRecordNoNull<M, T, K extends keyof M = keyof M> = ITSOmitByType<M, ITSNullPrimitive, K>;
74
+ export type ITSExcludeRecord<M, T, K extends keyof M = keyof M> = ITSOmitByType<M, T, K>;
75
+ export type ITSExcludeRecordNoNull<M, T, K extends keyof M = keyof M> = ITSOmitByType<M, ITSNullPrimitive, K>;
76
76
  /**
77
77
  * @deprecated use `ITSKeyofByExtractType<T, U, K>`
78
78
  */
79
- export declare type ITSExtractKeyofRecord<M, T, K extends keyof M = keyof M> = ITSKeyofByExtractType<M, T, K>;
79
+ export type ITSExtractKeyofRecord<M, T, K extends keyof M = keyof M> = ITSKeyofByExtractType<M, T, K>;
80
80
  /**
81
81
  * @deprecated use `ITSKeyofByExcludeType<M, T, K>`
82
82
  */
83
- export declare type ITSExcludeKeyofRecord<M, T, K extends keyof M = keyof M> = ITSKeyofByExcludeType<M, T, K>;
83
+ export type ITSExcludeKeyofRecord<M, T, K extends keyof M = keyof M> = ITSKeyofByExcludeType<M, T, K>;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * https://stackoverflow.com/a/55479659/4563339
3
3
  */
4
- export { ITSKeyIsPartialOfRecord } from './record/partial';
4
+ export type { ITSKeyIsPartialOfRecord } from './record/partial';
5
5
  /**
6
6
  * returns a union of the readonly keys of an Object.
7
7
  *
@@ -19,7 +19,7 @@ export { ITSKeyIsPartialOfRecord } from './record/partial';
19
19
  * type Keys = ITSKeyOfRecordExtractReadonly<Todo>
20
20
  * // expected to be "title" | "description"
21
21
  */
22
- export declare type ITSKeyOfRecordExtractReadonly<T> = {
22
+ export type ITSKeyOfRecordExtractReadonly<T> = {
23
23
  [K in keyof T]-?: (<U>() => U extends {
24
24
  -readonly [P in K]: T[K];
25
25
  } ? 1 : 2) extends (<U>() => U extends {
@@ -27,6 +27,6 @@ export declare type ITSKeyOfRecordExtractReadonly<T> = {
27
27
  } ? 1 : 2) ? never : K;
28
28
  }[keyof T];
29
29
  export type { ITSKeyOfRecordExtractReadonly as ITSGetReadonlyKeys };
30
- export declare type ITSKeyOfRecordExcludeReadonly<T> = Exclude<keyof T, ITSKeyOfRecordExtractReadonly<T>>;
31
- export declare type ITSKeyIsReadonlyOfRecord<T, K extends ITSKeyOfRecordExtractReadonly<T>> = Extract<K, ITSKeyOfRecordExtractReadonly<T>>;
32
- export declare type ITSKeyIsNotReadonlyOfRecord<T, K extends ITSKeyOfRecordExcludeReadonly<T>> = Extract<K, ITSKeyOfRecordExcludeReadonly<T>>;
30
+ export type ITSKeyOfRecordExcludeReadonly<T> = Exclude<keyof T, ITSKeyOfRecordExtractReadonly<T>>;
31
+ export type ITSKeyIsReadonlyOfRecord<T, K extends ITSKeyOfRecordExtractReadonly<T>> = Extract<K, ITSKeyOfRecordExtractReadonly<T>>;
32
+ export type ITSKeyIsNotReadonlyOfRecord<T, K extends ITSKeyOfRecordExcludeReadonly<T>> = Extract<K, ITSKeyOfRecordExcludeReadonly<T>>;
@@ -1 +1 @@
1
- {"version":3,"file":"record.js","sourceRoot":"","sources":["record.ts"],"names":[],"mappings":";AAAA;;GAEG","sourcesContent":["/**\n * https://stackoverflow.com/a/55479659/4563339\n */\n\nexport { ITSKeyIsPartialOfRecord } from './record/partial';\n\n/**\n * returns a union of the readonly keys of an Object.\n *\n * @see https://github.com/type-challenges/type-challenges/blob/master/questions/5-extreme-readonly-keys/README.md\n * @see https://github.com/type-challenges/type-challenges/issues/87\n *\n * @alias ITSGetReadonlyKeys\n *\n * @example\n * interface Todo {\n * readonly title: string\n * readonly description: string\n * completed: boolean\n * }\n * type Keys = ITSKeyOfRecordExtractReadonly<Todo>\n * // expected to be \"title\" | \"description\"\n */\nexport type ITSKeyOfRecordExtractReadonly<T> = {[K in keyof T]-?: (<U>() => U extends {-readonly [P in K]: T[K]} ? 1 : 2) extends (<U>() => U extends {[P in K]: T[K]} ? 1 : 2) ? never : K}[keyof T];\n\nexport type { ITSKeyOfRecordExtractReadonly as ITSGetReadonlyKeys }\n\nexport type ITSKeyOfRecordExcludeReadonly<T> = Exclude<keyof T, ITSKeyOfRecordExtractReadonly<T>>\n\nexport type ITSKeyIsReadonlyOfRecord<T, K extends ITSKeyOfRecordExtractReadonly<T>> = Extract<K, ITSKeyOfRecordExtractReadonly<T>>;\n\nexport type ITSKeyIsNotReadonlyOfRecord<T, K extends ITSKeyOfRecordExcludeReadonly<T>> = Extract<K, ITSKeyOfRecordExcludeReadonly<T>>;\n"]}
1
+ {"version":3,"file":"record.js","sourceRoot":"","sources":["record.ts"],"names":[],"mappings":";AAAA;;GAEG","sourcesContent":["/**\n * https://stackoverflow.com/a/55479659/4563339\n */\n\nexport type { ITSKeyIsPartialOfRecord } from './record/partial';\n\n/**\n * returns a union of the readonly keys of an Object.\n *\n * @see https://github.com/type-challenges/type-challenges/blob/master/questions/5-extreme-readonly-keys/README.md\n * @see https://github.com/type-challenges/type-challenges/issues/87\n *\n * @alias ITSGetReadonlyKeys\n *\n * @example\n * interface Todo {\n * readonly title: string\n * readonly description: string\n * completed: boolean\n * }\n * type Keys = ITSKeyOfRecordExtractReadonly<Todo>\n * // expected to be \"title\" | \"description\"\n */\nexport type ITSKeyOfRecordExtractReadonly<T> = {[K in keyof T]-?: (<U>() => U extends {-readonly [P in K]: T[K]} ? 1 : 2) extends (<U>() => U extends {[P in K]: T[K]} ? 1 : 2) ? never : K}[keyof T];\n\nexport type { ITSKeyOfRecordExtractReadonly as ITSGetReadonlyKeys }\n\nexport type ITSKeyOfRecordExcludeReadonly<T> = Exclude<keyof T, ITSKeyOfRecordExtractReadonly<T>>\n\nexport type ITSKeyIsReadonlyOfRecord<T, K extends ITSKeyOfRecordExtractReadonly<T>> = Extract<K, ITSKeyOfRecordExtractReadonly<T>>;\n\nexport type ITSKeyIsNotReadonlyOfRecord<T, K extends ITSKeyOfRecordExcludeReadonly<T>> = Extract<K, ITSKeyOfRecordExcludeReadonly<T>>;\n"]}
@@ -0,0 +1,6 @@
1
+ import { ITSToStringLiteralAllowedType } from '../string';
2
+ export type ITSStringInferToType<Str extends string, Type extends ITSToStringLiteralAllowedType, R = never> = Str extends `${infer U extends Type}` ? U : R;
3
+ export type ITSStringInferToNumber<Str extends string, R = never> = ITSStringInferToType<Str, number, R>;
4
+ export type ITSStringInferToBoolean<Str extends string, R = never> = ITSStringInferToType<Str, boolean, R>;
5
+ export type ITSStringInferToNull<Str extends string, R = never> = ITSStringInferToType<Str, null, R>;
6
+ export type ITSStringInferToUndefined<Str extends string, R = never> = ITSStringInferToType<Str, undefined, R>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=infer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infer.js","sourceRoot":"","sources":["infer.ts"],"names":[],"mappings":"","sourcesContent":["import { ITSToStringLiteralAllowedType } from '../string';\n\nexport type ITSStringInferToType<Str extends string, Type extends ITSToStringLiteralAllowedType, R = never> =\n\tStr extends `${infer U extends Type}`\n\t\t? U\n\t\t: R;\n\nexport type ITSStringInferToNumber<Str extends string, R = never> = ITSStringInferToType<Str, number, R>\n\nexport type ITSStringInferToBoolean<Str extends string, R = never> = ITSStringInferToType<Str, boolean, R>\n\nexport type ITSStringInferToNull<Str extends string, R = never> = ITSStringInferToType<Str, null, R>\n\nexport type ITSStringInferToUndefined<Str extends string, R = never> = ITSStringInferToType<Str, undefined, R>\n"]}
@@ -2,9 +2,9 @@
2
2
  * Convert literal string types like 'foo-bar' to 'FooBar'
3
3
  * @see yargs
4
4
  */
5
- export declare type ITSPascalCase<S extends string> = string extends S ? string : S extends `${infer T}-${infer U}` ? `${Capitalize<T>}${ITSPascalCase<U>}` : Capitalize<S>;
5
+ export type ITSPascalCase<S extends string> = string extends S ? string : S extends `${infer T}-${infer U}` ? `${Capitalize<T>}${ITSPascalCase<U>}` : Capitalize<S>;
6
6
  /**
7
7
  * Convert literal string types like 'foo-bar' to 'fooBar'
8
8
  * @see yargs
9
9
  */
10
- export declare type ITSCamelCase<S extends string> = string extends S ? string : S extends `${infer T}-${infer U}` ? `${T}${ITSPascalCase<U>}` : S;
10
+ export type ITSCamelCase<S extends string> = string extends S ? string : S extends `${infer T}-${infer U}` ? `${T}${ITSPascalCase<U>}` : S;
@@ -1,17 +1,17 @@
1
- export declare type ITSToStringLiteralAllowedType = string | number | boolean | bigint;
1
+ export type ITSToStringLiteralAllowedType = string | number | boolean | bigint;
2
2
  /**
3
3
  * `${T}`
4
4
  */
5
- export declare type ITSToStringLiteral<T extends ITSToStringLiteralAllowedType> = `${T}`;
5
+ export type ITSToStringLiteral<T extends ITSToStringLiteralAllowedType> = `${T}`;
6
6
  /**
7
7
  * T & `${T}`
8
8
  */
9
- export declare type ITSTypeAndStringLiteral<T extends ITSToStringLiteralAllowedType> = T | ITSToStringLiteral<T>;
9
+ export type ITSTypeAndStringLiteral<T extends ITSToStringLiteralAllowedType> = T | ITSToStringLiteral<T>;
10
10
  /**
11
11
  * S & `${T}`
12
12
  */
13
- export declare type ITSAndStringLiteral<T extends ITSToStringLiteralAllowedType, S = string> = S | ITSToStringLiteral<T>;
13
+ export type ITSAndStringLiteral<T extends ITSToStringLiteralAllowedType, S = string> = S | ITSToStringLiteral<T>;
14
14
  /**
15
15
  * S & T & `${T}`
16
16
  */
17
- export declare type ITSAndTypeAndStringLiteral<T extends ITSToStringLiteralAllowedType, S = string> = S | ITSTypeAndStringLiteral<T>;
17
+ export type ITSAndTypeAndStringLiteral<T extends ITSToStringLiteralAllowedType, S = string> = S | ITSTypeAndStringLiteral<T>;
@@ -5,4 +5,4 @@
5
5
  * ITSTupleKeys<[string, string, string]> = "0" | "1" | "2"
6
6
  * @see https://stackoverflow.com/questions/50374908/transform-union-type-to-intersection-type
7
7
  */
8
- export declare type ITSTupleKeys<T extends any[]> = Exclude<keyof T, keyof []>;
8
+ export type ITSTupleKeys<T extends any[]> = Exclude<keyof T, keyof []>;
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * Created by user on 2019/6/11.
3
3
  */
4
- export declare type ITSIteratorLazy<T extends Iterator<any> | IteratorResult<any>> = T extends IteratorResult<infer U> ? IteratorResult<U> : T extends Iterator<infer U> ? Iterator<U> : T;
5
- export declare type ITSTypeOfArrayLike<T extends any[]> = T extends (infer U)[] ? U : T extends ArrayLike<infer U> ? U : any;
6
- export declare type ITSTypeOfIterator<T extends ITSIteratorLazy<any>> = T extends Iterator<infer U> ? U : T extends IteratorResult<infer U> ? U : any;
4
+ export type ITSIteratorLazy<T extends Iterator<any> | IteratorResult<any>> = T extends IteratorResult<infer U> ? IteratorResult<U> : T extends Iterator<infer U> ? Iterator<U> : T;
5
+ export type ITSTypeOfIterator<T extends ITSIteratorLazy<any>> = T extends Iterator<infer U> ? U : T extends IteratorResult<infer U> ? U : any;
@@ -1 +1 @@
1
- {"version":3,"file":"typeof.js","sourceRoot":"","sources":["typeof.ts"],"names":[],"mappings":";AAAA;;GAEG","sourcesContent":["/**\n * Created by user on 2019/6/11.\n */\n\n\nexport type ITSIteratorLazy<T extends Iterator<any> | IteratorResult<any>> =\n//\tT\n\tT extends IteratorResult<infer U> ? IteratorResult<U> :\n\t\tT extends Iterator<infer U> ? Iterator<U> :\n\t\t\tT\n\t;\n\nexport type ITSTypeOfArrayLike<T extends any[]> =\n\tT extends (infer U)[] ? U :\n\t\tT extends ArrayLike<infer U> ? U :\n\t\t\tany\n\t;\n\nexport type ITSTypeOfIterator<T extends ITSIteratorLazy<any>> =\n\tT extends Iterator<infer U> ? U :\n\t\tT extends IteratorResult<infer U> ? U :\n\t\t\tany\n\t;\n"]}
1
+ {"version":3,"file":"typeof.js","sourceRoot":"","sources":["typeof.ts"],"names":[],"mappings":";AAAA;;GAEG","sourcesContent":["/**\n * Created by user on 2019/6/11.\n */\n\n\nexport type ITSIteratorLazy<T extends Iterator<any> | IteratorResult<any>> =\n//\tT\n\tT extends IteratorResult<infer U> ? IteratorResult<U> :\n\t\tT extends Iterator<infer U> ? Iterator<U> :\n\t\t\tT\n\t;\n\nexport type ITSTypeOfIterator<T extends ITSIteratorLazy<any>> =\n\tT extends Iterator<infer U> ? U :\n\t\tT extends IteratorResult<infer U> ? U :\n\t\t\tany\n\t;\n"]}
package/lib/helper.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ITSArrayListMaybeReadonly } from './type/base';
2
- import { ITSUnpackedReturnType } from './helper/unpacked';
2
+ import { ITSAwaitedReturnType } from './helper/promise';
3
3
  /**
4
4
  * copy current function with Parameters and return to new value
5
5
  *
@@ -10,13 +10,11 @@ import { ITSUnpackedReturnType } from './helper/unpacked';
10
10
  * declare let c: ITSOverwriteReturnType<typeof f, string>;
11
11
  * // c = (a: number) => string
12
12
  */
13
- export declare type ITSOverwriteReturnType<T extends (...args: any[]) => any, R extends unknown> = (...args: Parameters<T>) => R;
14
- export declare type ITSWrapFunctionPromiseLike<T extends (...args: any[]) => any> = (...args: Parameters<T>) => PromiseLike<ITSUnpackedReturnType<T>>;
15
- export declare type ITSWrapFunctionPromise<T extends (...args: any[]) => any> = (...args: Parameters<T>) => Promise<ITSUnpackedReturnType<T>>;
13
+ export type ITSOverwriteReturnType<T extends (...args: any[]) => any, R extends unknown> = (...args: Parameters<T>) => R;
14
+ export type ITSWrapFunctionPromiseLike<T extends (...args: any[]) => any> = (...args: Parameters<T>) => PromiseLike<ITSAwaitedReturnType<T>>;
15
+ export type ITSWrapFunctionPromise<T extends (...args: any[]) => any> = (...args: Parameters<T>) => Promise<ITSAwaitedReturnType<T>>;
16
16
  /**
17
17
  * @deprecated
18
18
  */
19
- export declare type ITSExtendsOf<T, U> = Extract<T, U>;
20
- export declare type ITSKeyOfArray<T extends ITSArrayListMaybeReadonly<any>> = Exclude<keyof T, symbol | string>;
21
- export declare type ITSValueOfArray<T extends ITSArrayListMaybeReadonly<any>> = T extends (infer U)[] ? U : never;
22
- export declare type ITSValueOfRecord<T extends Record<any, any>> = T[keyof T];
19
+ export type ITSExtendsOf<T, U> = Extract<T, U>;
20
+ export type ITSKeyOfArray<T extends ITSArrayListMaybeReadonly<any>> = Exclude<keyof T, symbol | string>;