type-plus 6.5.0 → 6.7.0

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 (214) hide show
  1. package/README.md +27 -15
  2. package/cjs/any/any_or_never.d.ts +0 -2
  3. package/cjs/any/any_or_never.d.ts.map +1 -1
  4. package/cjs/any/any_type.d.ts +2 -6
  5. package/cjs/any/any_type.d.ts.map +1 -1
  6. package/cjs/array/array.d.ts +0 -4
  7. package/cjs/array/array.d.ts.map +1 -1
  8. package/cjs/array/array_index.d.ts +7 -10
  9. package/cjs/array/array_index.d.ts.map +1 -1
  10. package/cjs/array/array_type.d.ts +0 -8
  11. package/cjs/array/array_type.d.ts.map +1 -1
  12. package/cjs/bigint/bigint_type.d.ts +4 -12
  13. package/cjs/bigint/bigint_type.d.ts.map +1 -1
  14. package/cjs/bigint/strict_bigint_type.d.ts +4 -12
  15. package/cjs/bigint/strict_bigint_type.d.ts.map +1 -1
  16. package/cjs/boolean/boolean_type.d.ts +0 -8
  17. package/cjs/boolean/boolean_type.d.ts.map +1 -1
  18. package/cjs/boolean/false_type.d.ts +0 -8
  19. package/cjs/boolean/false_type.d.ts.map +1 -1
  20. package/cjs/boolean/strict_boolean_type.d.ts +0 -8
  21. package/cjs/boolean/strict_boolean_type.d.ts.map +1 -1
  22. package/cjs/boolean/true_type.d.ts +0 -8
  23. package/cjs/boolean/true_type.d.ts.map +1 -1
  24. package/cjs/equal/equal.d.ts +4 -5
  25. package/cjs/equal/equal.d.ts.map +1 -1
  26. package/cjs/function/function_type.d.ts +0 -8
  27. package/cjs/function/function_type.d.ts.map +1 -1
  28. package/cjs/function/strict_function_type.d.ts +0 -8
  29. package/cjs/function/strict_function_type.d.ts.map +1 -1
  30. package/cjs/index.d.ts +3 -0
  31. package/cjs/index.d.ts.map +1 -1
  32. package/cjs/index.js.map +1 -1
  33. package/cjs/never/never_type.d.ts +2 -10
  34. package/cjs/never/never_type.d.ts.map +1 -1
  35. package/cjs/null/null_type.d.ts +4 -12
  36. package/cjs/null/null_type.d.ts.map +1 -1
  37. package/cjs/number/integer.d.ts +1 -9
  38. package/cjs/number/integer.d.ts.map +1 -1
  39. package/cjs/number/negative.d.ts +0 -8
  40. package/cjs/number/negative.d.ts.map +1 -1
  41. package/cjs/number/number_type.d.ts +0 -8
  42. package/cjs/number/number_type.d.ts.map +1 -1
  43. package/cjs/number/numeric_type.d.ts +0 -8
  44. package/cjs/number/numeric_type.d.ts.map +1 -1
  45. package/cjs/number/positive.d.ts +1 -9
  46. package/cjs/number/positive.d.ts.map +1 -1
  47. package/cjs/number/strict_number_type.d.ts +4 -12
  48. package/cjs/number/strict_number_type.d.ts.map +1 -1
  49. package/cjs/object/object_type.d.ts +1 -9
  50. package/cjs/object/object_type.d.ts.map +1 -1
  51. package/cjs/string/strict_string_type.d.ts +14 -19
  52. package/cjs/string/strict_string_type.d.ts.map +1 -1
  53. package/cjs/string/string.d.ts +24 -0
  54. package/cjs/string/string.d.ts.map +1 -0
  55. package/cjs/string/string.js +3 -0
  56. package/cjs/string/string.js.map +1 -0
  57. package/cjs/string/string_plus.d.ts +27 -0
  58. package/cjs/string/string_plus.d.ts.map +1 -0
  59. package/cjs/string/string_plus.js +3 -0
  60. package/cjs/string/string_plus.js.map +1 -0
  61. package/cjs/string/string_type.d.ts +4 -12
  62. package/cjs/string/string_type.d.ts.map +1 -1
  63. package/cjs/symbol/symbol_type.d.ts +5 -15
  64. package/cjs/symbol/symbol_type.d.ts.map +1 -1
  65. package/cjs/testing/stub.d.ts +4 -2
  66. package/cjs/testing/stub.d.ts.map +1 -1
  67. package/cjs/testing/stub.js.map +1 -1
  68. package/cjs/tuple/tuple_type.d.ts +0 -8
  69. package/cjs/tuple/tuple_type.d.ts.map +1 -1
  70. package/cjs/type/failed.d.ts +2 -3
  71. package/cjs/type/failed.d.ts.map +1 -1
  72. package/cjs/type/failed.js +0 -1
  73. package/cjs/type/failed.js.map +1 -1
  74. package/cjs/type/no_infer.d.ts +24 -0
  75. package/cjs/type/no_infer.d.ts.map +1 -0
  76. package/cjs/type/no_infer.js +3 -0
  77. package/cjs/type/no_infer.js.map +1 -0
  78. package/cjs/undefined/undefined_type.d.ts +4 -12
  79. package/cjs/undefined/undefined_type.d.ts.map +1 -1
  80. package/cjs/unknown/unknown_type.d.ts +4 -12
  81. package/cjs/unknown/unknown_type.d.ts.map +1 -1
  82. package/cjs/void/void_type.d.ts +0 -8
  83. package/cjs/void/void_type.d.ts.map +1 -1
  84. package/esm/any/any_or_never.d.ts +0 -2
  85. package/esm/any/any_or_never.d.ts.map +1 -1
  86. package/esm/any/any_type.d.ts +2 -6
  87. package/esm/any/any_type.d.ts.map +1 -1
  88. package/esm/array/array.d.ts +0 -4
  89. package/esm/array/array.d.ts.map +1 -1
  90. package/esm/array/array_index.d.ts +7 -10
  91. package/esm/array/array_index.d.ts.map +1 -1
  92. package/esm/array/array_type.d.ts +0 -8
  93. package/esm/array/array_type.d.ts.map +1 -1
  94. package/esm/bigint/bigint_type.d.ts +4 -12
  95. package/esm/bigint/bigint_type.d.ts.map +1 -1
  96. package/esm/bigint/strict_bigint_type.d.ts +4 -12
  97. package/esm/bigint/strict_bigint_type.d.ts.map +1 -1
  98. package/esm/boolean/boolean_type.d.ts +0 -8
  99. package/esm/boolean/boolean_type.d.ts.map +1 -1
  100. package/esm/boolean/false_type.d.ts +0 -8
  101. package/esm/boolean/false_type.d.ts.map +1 -1
  102. package/esm/boolean/strict_boolean_type.d.ts +0 -8
  103. package/esm/boolean/strict_boolean_type.d.ts.map +1 -1
  104. package/esm/boolean/true_type.d.ts +0 -8
  105. package/esm/boolean/true_type.d.ts.map +1 -1
  106. package/esm/equal/equal.d.ts +4 -5
  107. package/esm/equal/equal.d.ts.map +1 -1
  108. package/esm/function/function_type.d.ts +0 -8
  109. package/esm/function/function_type.d.ts.map +1 -1
  110. package/esm/function/strict_function_type.d.ts +0 -8
  111. package/esm/function/strict_function_type.d.ts.map +1 -1
  112. package/esm/index.d.ts +3 -0
  113. package/esm/index.d.ts.map +1 -1
  114. package/esm/index.js.map +1 -1
  115. package/esm/never/never_type.d.ts +2 -10
  116. package/esm/never/never_type.d.ts.map +1 -1
  117. package/esm/null/null_type.d.ts +4 -12
  118. package/esm/null/null_type.d.ts.map +1 -1
  119. package/esm/number/integer.d.ts +1 -9
  120. package/esm/number/integer.d.ts.map +1 -1
  121. package/esm/number/negative.d.ts +0 -8
  122. package/esm/number/negative.d.ts.map +1 -1
  123. package/esm/number/number_type.d.ts +0 -8
  124. package/esm/number/number_type.d.ts.map +1 -1
  125. package/esm/number/numeric_type.d.ts +0 -8
  126. package/esm/number/numeric_type.d.ts.map +1 -1
  127. package/esm/number/positive.d.ts +1 -9
  128. package/esm/number/positive.d.ts.map +1 -1
  129. package/esm/number/strict_number_type.d.ts +4 -12
  130. package/esm/number/strict_number_type.d.ts.map +1 -1
  131. package/esm/object/object_type.d.ts +1 -9
  132. package/esm/object/object_type.d.ts.map +1 -1
  133. package/esm/string/strict_string_type.d.ts +14 -19
  134. package/esm/string/strict_string_type.d.ts.map +1 -1
  135. package/esm/string/string.d.ts +24 -0
  136. package/esm/string/string.d.ts.map +1 -0
  137. package/esm/string/string.js +2 -0
  138. package/esm/string/string.js.map +1 -0
  139. package/esm/string/string_plus.d.ts +27 -0
  140. package/esm/string/string_plus.d.ts.map +1 -0
  141. package/esm/string/string_plus.js +2 -0
  142. package/esm/string/string_plus.js.map +1 -0
  143. package/esm/string/string_type.d.ts +4 -12
  144. package/esm/string/string_type.d.ts.map +1 -1
  145. package/esm/symbol/symbol_type.d.ts +5 -15
  146. package/esm/symbol/symbol_type.d.ts.map +1 -1
  147. package/esm/testing/stub.d.ts +4 -2
  148. package/esm/testing/stub.d.ts.map +1 -1
  149. package/esm/testing/stub.js.map +1 -1
  150. package/esm/tuple/tuple_type.d.ts +0 -8
  151. package/esm/tuple/tuple_type.d.ts.map +1 -1
  152. package/esm/type/failed.d.ts +2 -3
  153. package/esm/type/failed.d.ts.map +1 -1
  154. package/esm/type/failed.js +1 -1
  155. package/esm/type/failed.js.map +1 -1
  156. package/esm/type/no_infer.d.ts +24 -0
  157. package/esm/type/no_infer.d.ts.map +1 -0
  158. package/esm/type/no_infer.js +2 -0
  159. package/esm/type/no_infer.js.map +1 -0
  160. package/esm/undefined/undefined_type.d.ts +4 -12
  161. package/esm/undefined/undefined_type.d.ts.map +1 -1
  162. package/esm/unknown/unknown_type.d.ts +4 -12
  163. package/esm/unknown/unknown_type.d.ts.map +1 -1
  164. package/esm/void/void_type.d.ts +0 -8
  165. package/esm/void/void_type.d.ts.map +1 -1
  166. package/package.json +3 -3
  167. package/ts/any/any_or_never.ts +0 -2
  168. package/ts/any/any_type.ts +2 -6
  169. package/ts/array/array.ts +0 -4
  170. package/ts/array/array_index.ts +7 -10
  171. package/ts/array/array_type.ts +0 -8
  172. package/ts/bigint/bigint_type.ts +4 -12
  173. package/ts/bigint/strict_bigint_type.ts +4 -12
  174. package/ts/boolean/boolean_type.ts +0 -8
  175. package/ts/boolean/false_type.ts +0 -8
  176. package/ts/boolean/strict_boolean_type.ts +0 -8
  177. package/ts/boolean/true_type.ts +0 -8
  178. package/ts/equal/equal.ts +9 -5
  179. package/ts/equal/readme.md +3 -0
  180. package/ts/function/function_type.ts +0 -8
  181. package/ts/function/strict_function_type.ts +0 -8
  182. package/ts/index.ts +3 -0
  183. package/ts/never/never_type.ts +2 -10
  184. package/ts/null/null_type.ts +4 -12
  185. package/ts/number/integer.ts +1 -9
  186. package/ts/number/negative.ts +0 -8
  187. package/ts/number/number_type.ts +0 -8
  188. package/ts/number/numeric_type.ts +0 -8
  189. package/ts/number/positive.ts +1 -9
  190. package/ts/number/strict_number_type.ts +4 -12
  191. package/ts/object/object_type.ts +1 -9
  192. package/ts/string/readme.md +5 -0
  193. package/ts/string/strict_string_type.ts +15 -19
  194. package/ts/string/string.ts +36 -0
  195. package/ts/string/string_plus.ts +33 -0
  196. package/ts/string/string_type.ts +4 -12
  197. package/ts/symbol/symbol_type.ts +5 -17
  198. package/ts/testing/stub.ts +6 -3
  199. package/ts/tuple/tuple_type.ts +0 -8
  200. package/ts/type/failed.ts +1 -3
  201. package/ts/type/no_infer.ts +24 -0
  202. package/ts/type/readme.md +36 -0
  203. package/ts/undefined/undefined_type.ts +4 -12
  204. package/ts/unknown/unknown_type.ts +4 -12
  205. package/ts/void/void_type.ts +0 -8
  206. package/cjs/type/constants.d.ts +0 -5
  207. package/cjs/type/constants.d.ts.map +0 -1
  208. package/cjs/type/constants.js +0 -8
  209. package/cjs/type/constants.js.map +0 -1
  210. package/esm/type/constants.d.ts +0 -5
  211. package/esm/type/constants.d.ts.map +0 -1
  212. package/esm/type/constants.js +0 -5
  213. package/esm/type/constants.js.map +0 -1
  214. package/ts/type/constants.ts +0 -4
@@ -0,0 +1,36 @@
1
+ # type
2
+
3
+ General type utilities.
4
+
5
+ ## Failed
6
+
7
+ `Failed<Msg>` is a type to describe a failure.
8
+
9
+ Use the same concept to create your own failure types.
10
+
11
+ ```ts
12
+ import { type Failed } from 'type-plus'
13
+
14
+ type YourComplexType<A,B,C> = A extends B ?
15
+ ... // and many more hard work later...
16
+ : Failed<'you are doing something wrong!'>
17
+ ```
18
+
19
+ [![Just Code: I failed][failed-type]][failed-type-url]
20
+
21
+ ## NoInfer
22
+
23
+ `NoInfer<T>` is a type to prevent type inference.
24
+
25
+ ```ts
26
+ import { type NoInfer } from 'type-plus'
27
+
28
+ function assertEqual<T>(a: T, b: NoInfer<T>) {
29
+ return a === b
30
+ }
31
+
32
+ function stub<T>(v: RecursivePartial<NoInfer<T>>): T { return v }
33
+ ```
34
+
35
+ [failed-type]: https://img.youtube.com/vi/3pEXVe6KJO4/0.jpg
36
+ [failed-type-url]: https://www.youtube.com/live/3pEXVe6KJO4
@@ -3,9 +3,7 @@ import type { IsAny } from '../any/any_type.js'
3
3
  /**
4
4
  * Check if the type `T` is exactly `undefined`.
5
5
  *
6
- * ```
7
- * import type { UndefinedType } from 'type-plus'
8
- *
6
+ * ```ts
9
7
  * type R = UndefinedType<undefined> // undefined
10
8
  *
11
9
  * type R = UndefinedType<never> // never
@@ -22,9 +20,7 @@ export type UndefinedType<T, Then = T, Else = never> = IsAny<
22
20
  /**
23
21
  * Is the type `T` exactly `undefined`.
24
22
  *
25
- * ```
26
- * import type { IsUndefined } from 'type-plus'
27
- *
23
+ * ```ts
28
24
  * type R = IsUndefined<undefined> // true
29
25
  *
30
26
  * type R = IsUndefined<never> // false
@@ -37,9 +33,7 @@ export type IsUndefined<T, Then = true, Else = false> = UndefinedType<T, Then, E
37
33
  /**
38
34
  * Check if the type `T` is not `undefined`.
39
35
  *
40
- * ```
41
- * import type { NotUndefinedType } from 'type-plus'
42
- *
36
+ * ```ts
43
37
  * type R = NotUndefinedType<undefined> // never
44
38
  *
45
39
  * type R = NotUndefinedType<never> // never
@@ -52,9 +46,7 @@ export type NotUndefinedType<T, Then = T, Else = never> = UndefinedType<T, Else,
52
46
  /**
53
47
  * Is the type `T` not `undefined`.
54
48
  *
55
- * ```
56
- * import type { IsNotUndefined } from 'type-plus'
57
- *
49
+ * ```ts
58
50
  * type R = IsNotUndefined<undefined> // false
59
51
  *
60
52
  * type R = IsNotUndefined<never> // true
@@ -3,9 +3,7 @@ import type { IsAny } from '../any/any_type.js'
3
3
  /**
4
4
  * Check if the type `T` is exactly `unknown`.
5
5
  *
6
- * ```
7
- * import type { UnknownType } from 'type-plus'
8
- *
6
+ * ```ts
9
7
  * type R = UnknownType<unknown> // unknown
10
8
  *
11
9
  * type R = UnknownType<number> // never
@@ -21,9 +19,7 @@ export type UnknownType<T, Then = T, Else = never> = IsAny<
21
19
  /**
22
20
  * Is the type `T` exactly `unknown`.
23
21
  *
24
- * ```
25
- * import type { IsUnknown } from 'type-plus'
26
- *
22
+ * ```ts
27
23
  * type R = IsUnknown<unknown> // true
28
24
  *
29
25
  * type R = IsUnknown<number> // false
@@ -35,9 +31,7 @@ export type IsUnknown<T, Then = true, Else = false> = UnknownType<T, Then, Else>
35
31
  /**
36
32
  * Check if the type `T` is not `unknown`.
37
33
  *
38
- * ```
39
- * import type { NotUnknownType } from 'type-plus'
40
- *
34
+ * ```ts
41
35
  * type R = NotUnknownType<unknown> // never
42
36
  *
43
37
  * type R = NotUnknownType<never> // never
@@ -50,9 +44,7 @@ export type NotUnknownType<T, Then = T, Else = never> = UnknownType<T, Else, The
50
44
  /**
51
45
  * Is the type `T` not exactly `unknown`.
52
46
  *
53
- * ```
54
- * import type { IsNotUnknown } from 'type-plus'
55
- *
47
+ * ```ts
56
48
  * type R = IsNotUnknown<unknown> // false
57
49
  *
58
50
  * type R = IsNotUnknown<never> // true
@@ -5,8 +5,6 @@ import type { IsUndefined } from '../undefined/undefined_type.js'
5
5
  * Check if `T` is `void`.
6
6
  *
7
7
  * ```ts
8
- * import type { VoidType } from 'type-plus'
9
- *
10
8
  * type R = VoidType<void> // void
11
9
  *
12
10
  * type R = VoidType<1> // never
@@ -22,8 +20,6 @@ export type VoidType<T, Then = T, Else = never> = IsAnyOrNever<
22
20
  * Check if `T` is not `void`.
23
21
  *
24
22
  * ```ts
25
- * import type { VoidType } from 'type-plus'
26
- *
27
23
  * type R = VoidType<void> // never
28
24
  *
29
25
  * type R = VoidType<1> // 1
@@ -35,8 +31,6 @@ export type NotVoidType<T, Then = T, Else = never> = VoidType<T, Else, Then>
35
31
  * Is `T` `void`.
36
32
  *
37
33
  * ```ts
38
- * import type { IsVoid } from 'type-plus'
39
- *
40
34
  * type R = IsVoid<void> // true
41
35
  *
42
36
  * type R = IsVoid<1> // false
@@ -48,8 +42,6 @@ export type IsVoid<T, Then = true, Else = false> = VoidType<T, Then, Else>
48
42
  * Is `T` not `void`.
49
43
  *
50
44
  * ```ts
51
- * import type { IsNotVoid } from 'type-plus'
52
- *
53
45
  * type R = IsNotVoid<void> // false
54
46
  *
55
47
  * type R = IsNotVoid<1> // true
@@ -1,5 +0,0 @@
1
- /**
2
- * This is a internal symbol to create branded types.
3
- */
4
- export declare const uniSym: unique symbol;
5
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../ts/type/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,MAAM,eAAsB,CAAA"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.uniSym = void 0;
4
- /**
5
- * This is a internal symbol to create branded types.
6
- */
7
- exports.uniSym = Symbol('type-plus');
8
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../ts/type/constants.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA"}
@@ -1,5 +0,0 @@
1
- /**
2
- * This is a internal symbol to create branded types.
3
- */
4
- export declare const uniSym: unique symbol;
5
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../ts/type/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,MAAM,eAAsB,CAAA"}
@@ -1,5 +0,0 @@
1
- /**
2
- * This is a internal symbol to create branded types.
3
- */
4
- export const uniSym = Symbol('type-plus');
5
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../ts/type/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAA"}
@@ -1,4 +0,0 @@
1
- /**
2
- * This is a internal symbol to create branded types.
3
- */
4
- export const uniSym = Symbol('type-plus')