@layerzerolabs/typescript-utils 0.2.67 → 0.2.69
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.
- package/package.json +6 -3
- package/.turbo/turbo-build.log +0 -178
- package/.turbo/turbo-lint.log +0 -8
- package/src/advancedRecord.ts +0 -23
- package/src/asyncify.ts +0 -5
- package/src/branded.ts +0 -19
- package/src/constructor.ts +0 -1
- package/src/deep.test-d.ts +0 -33
- package/src/deep.ts +0 -26
- package/src/disallowedAny.ts +0 -5
- package/src/identity.ts +0 -2
- package/src/index.ts +0 -17
- package/src/lastOf.ts +0 -15
- package/src/maybeUndefined.ts +0 -16
- package/src/merge.ts +0 -13
- package/src/methodOf.ts +0 -7
- package/src/removeNever.ts +0 -3
- package/src/strings.test-d.ts +0 -32
- package/src/strings.ts +0 -42
- package/src/tuples.ts +0 -65
- package/src/valueOf.ts +0 -16
- package/src/viem.ts +0 -275
- package/src/withRequired.ts +0 -5
- package/test/disallowedAny.test.ts +0 -54
- package/test/merge.test.ts +0 -27
- package/tsconfig.json +0 -20
- package/tsup.config.ts +0 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/typescript-utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.69",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -13,11 +13,14 @@
|
|
|
13
13
|
"main": "./dist/index.cjs",
|
|
14
14
|
"module": "./dist/index.js",
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/**/*"
|
|
18
|
+
],
|
|
16
19
|
"devDependencies": {
|
|
17
20
|
"tsup": "^8.4.0",
|
|
18
21
|
"vitest": "^3.2.3",
|
|
19
|
-
"@layerzerolabs/tsup-configuration": "0.2.
|
|
20
|
-
"@layerzerolabs/typescript-configuration": "0.2.
|
|
22
|
+
"@layerzerolabs/tsup-configuration": "0.2.69",
|
|
23
|
+
"@layerzerolabs/typescript-configuration": "0.2.69"
|
|
21
24
|
},
|
|
22
25
|
"publishConfig": {
|
|
23
26
|
"access": "public",
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
WARN Issue while reading "/home/runner/work/monorepo-internal/monorepo-internal/.npmrc". Failed to replace env in config: ${NPM_TOKEN}
|
|
2
|
-
|
|
3
|
-
> @layerzerolabs/typescript-utils@0.0.0 build /home/runner/work/monorepo-internal/monorepo-internal/packages/typescript-utils
|
|
4
|
-
> tsup
|
|
5
|
-
|
|
6
|
-
[34mCLI[39m Building entry: src/advancedRecord.ts, src/asyncify.ts, src/branded.ts, src/constructor.ts, src/deep.test-d.ts, src/deep.ts, src/disallowedAny.ts, src/identity.ts, src/index.ts, src/lastOf.ts, src/maybeUndefined.ts, src/merge.ts, src/methodOf.ts, src/removeNever.ts, src/strings.test-d.ts, src/strings.ts, src/tuples.ts, src/valueOf.ts, src/viem.ts, src/withRequired.ts
|
|
7
|
-
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
8
|
-
[34mCLI[39m tsup v8.5.1
|
|
9
|
-
[34mCLI[39m Using tsup config: /home/runner/work/monorepo-internal/monorepo-internal/packages/typescript-utils/tsup.config.ts
|
|
10
|
-
[34mCLI[39m Target: ES2023
|
|
11
|
-
[34mCLI[39m Cleaning output folder
|
|
12
|
-
[34mCJS[39m Build start
|
|
13
|
-
[34mESM[39m Build start
|
|
14
|
-
Entry module "dist/EUBM3LSR.cjs" is using named and default exports together. Consumers of your bundle will have to use `chunk.default` to access the default export, which may not be what you want. Use `output.exports: "named"` to disable this warning.
|
|
15
|
-
"default" is imported from external module "path" but never used in "dist/6AHA7PAZ.js".
|
|
16
|
-
"fileURLToPath" is imported from external module "url" but never used in "dist/6AHA7PAZ.js".
|
|
17
|
-
[32mCJS[39m [1mdist/valueOf.cjs [22m[32m143.00 B[39m
|
|
18
|
-
[32mCJS[39m [1mdist/withRequired.cjs [22m[32m153.00 B[39m
|
|
19
|
-
[32mCJS[39m [1mdist/index.cjs [22m[32m639.00 B[39m
|
|
20
|
-
[32mCJS[39m [1mdist/viem.cjs [22m[32m137.00 B[39m
|
|
21
|
-
[32mCJS[39m [1mdist/KQUDWU4T.cjs [22m[32m187.00 B[39m
|
|
22
|
-
[32mCJS[39m [1mdist/tuples.cjs [22m[32m141.00 B[39m
|
|
23
|
-
[32mCJS[39m [1mdist/2MZ52QXI.cjs [22m[32m188.00 B[39m
|
|
24
|
-
[32mCJS[39m [1mdist/EUBM3LSR.cjs [22m[32m42.53 KB[39m
|
|
25
|
-
[32mCJS[39m [1mdist/B4TXK443.cjs [22m[32m185.00 B[39m
|
|
26
|
-
[32mCJS[39m [1mdist/4W25K7RR.cjs [22m[32m193.00 B[39m
|
|
27
|
-
[32mCJS[39m [1mdist/lastOf.cjs [22m[32m141.00 B[39m
|
|
28
|
-
[32mCJS[39m [1mdist/2OSBYVBM.cjs [22m[32m187.00 B[39m
|
|
29
|
-
[32mCJS[39m [1mdist/7RPBI4LQ.cjs [22m[32m195.00 B[39m
|
|
30
|
-
[32mCJS[39m [1mdist/maybeUndefined.cjs [22m[32m157.00 B[39m
|
|
31
|
-
[32mCJS[39m [1mdist/merge.cjs [22m[32m139.00 B[39m
|
|
32
|
-
[32mCJS[39m [1mdist/AKBGASRF.cjs [22m[32m186.00 B[39m
|
|
33
|
-
[32mCJS[39m [1mdist/methodOf.cjs [22m[32m145.00 B[39m
|
|
34
|
-
[32mCJS[39m [1mdist/removeNever.cjs [22m[32m151.00 B[39m
|
|
35
|
-
[32mCJS[39m [1mdist/NKWLAYNJ.cjs [22m[32m189.00 B[39m
|
|
36
|
-
[32mCJS[39m [1mdist/K3FZ3EZT.cjs [22m[32m188.00 B[39m
|
|
37
|
-
[32mCJS[39m [1mdist/strings.cjs [22m[32m143.00 B[39m
|
|
38
|
-
[32mCJS[39m [1mdist/Q35ZNXMT.cjs [22m[32m192.00 B[39m
|
|
39
|
-
[32mCJS[39m [1mdist/advancedRecord.cjs [22m[32m157.00 B[39m
|
|
40
|
-
[32mCJS[39m [1mdist/C7GMKBCN.cjs [22m[32m195.00 B[39m
|
|
41
|
-
[32mCJS[39m [1mdist/asyncify.cjs [22m[32m145.00 B[39m
|
|
42
|
-
[32mCJS[39m [1mdist/strings.test-d.cjs [22m[32m893.00 B[39m
|
|
43
|
-
[32mCJS[39m [1mdist/WPET3HPL.cjs [22m[32m189.00 B[39m
|
|
44
|
-
[32mCJS[39m [1mdist/53OHF4EH.cjs [22m[32m192.00 B[39m
|
|
45
|
-
[32mCJS[39m [1mdist/branded.cjs [22m[32m143.00 B[39m
|
|
46
|
-
[32mCJS[39m [1mdist/2SJJDCZI.cjs [22m[32m188.00 B[39m
|
|
47
|
-
[32mCJS[39m [1mdist/constructor.cjs [22m[32m151.00 B[39m
|
|
48
|
-
[32mCJS[39m [1mdist/deep.test-d.cjs [22m[32m574.00 B[39m
|
|
49
|
-
[32mCJS[39m [1mdist/deep.cjs [22m[32m137.00 B[39m
|
|
50
|
-
[32mCJS[39m [1mdist/MLSONTXK.cjs [22m[32m185.00 B[39m
|
|
51
|
-
[32mCJS[39m [1mdist/disallowedAny.cjs [22m[32m155.00 B[39m
|
|
52
|
-
[32mCJS[39m [1mdist/574X5FJM.cjs [22m[32m194.00 B[39m
|
|
53
|
-
[32mCJS[39m [1mdist/identity.cjs [22m[32m145.00 B[39m
|
|
54
|
-
[32mCJS[39m [1mdist/TVCGTTL5.cjs [22m[32m189.00 B[39m
|
|
55
|
-
[32mCJS[39m [1mdist/24WEKBY3.cjs [22m[32m2.10 KB[39m
|
|
56
|
-
[32mCJS[39m [1mdist/QXEVXGNQ.cjs [22m[32m301.19 KB[39m
|
|
57
|
-
[32mCJS[39m [1mdist/valueOf.cjs.map [22m[32m72.00 B[39m
|
|
58
|
-
[32mCJS[39m [1mdist/withRequired.cjs.map [22m[32m77.00 B[39m
|
|
59
|
-
[32mCJS[39m [1mdist/index.cjs.map [22m[32m665.00 B[39m
|
|
60
|
-
[32mCJS[39m [1mdist/tuples.cjs.map [22m[32m71.00 B[39m
|
|
61
|
-
[32mCJS[39m [1mdist/KQUDWU4T.cjs.map [22m[32m2.68 KB[39m
|
|
62
|
-
[32mCJS[39m [1mdist/2MZ52QXI.cjs.map [22m[32m538.00 B[39m
|
|
63
|
-
[32mCJS[39m [1mdist/viem.cjs.map [22m[32m69.00 B[39m
|
|
64
|
-
[32mCJS[39m [1mdist/B4TXK443.cjs.map [22m[32m8.26 KB[39m
|
|
65
|
-
[32mCJS[39m [1mdist/EUBM3LSR.cjs.map [22m[32m100.19 KB[39m
|
|
66
|
-
[32mCJS[39m [1mdist/4W25K7RR.cjs.map [22m[32m299.00 B[39m
|
|
67
|
-
[32mCJS[39m [1mdist/lastOf.cjs.map [22m[32m71.00 B[39m
|
|
68
|
-
[32mCJS[39m [1mdist/7RPBI4LQ.cjs.map [22m[32m642.00 B[39m
|
|
69
|
-
[32mCJS[39m [1mdist/2OSBYVBM.cjs.map [22m[32m659.00 B[39m
|
|
70
|
-
[32mCJS[39m [1mdist/maybeUndefined.cjs.map [22m[32m79.00 B[39m
|
|
71
|
-
[32mCJS[39m [1mdist/merge.cjs.map [22m[32m70.00 B[39m
|
|
72
|
-
[32mCJS[39m [1mdist/AKBGASRF.cjs.map [22m[32m469.00 B[39m
|
|
73
|
-
[32mCJS[39m [1mdist/methodOf.cjs.map [22m[32m73.00 B[39m
|
|
74
|
-
[32mCJS[39m [1mdist/removeNever.cjs.map [22m[32m76.00 B[39m
|
|
75
|
-
[32mCJS[39m [1mdist/strings.cjs.map [22m[32m72.00 B[39m
|
|
76
|
-
[32mCJS[39m [1mdist/NKWLAYNJ.cjs.map [22m[32m399.00 B[39m
|
|
77
|
-
[32mCJS[39m [1mdist/Q35ZNXMT.cjs.map [22m[32m252.00 B[39m
|
|
78
|
-
[32mCJS[39m [1mdist/K3FZ3EZT.cjs.map [22m[32m1.42 KB[39m
|
|
79
|
-
[32mCJS[39m [1mdist/C7GMKBCN.cjs.map [22m[32m906.00 B[39m
|
|
80
|
-
[32mCJS[39m [1mdist/advancedRecord.cjs.map [22m[32m79.00 B[39m
|
|
81
|
-
[32mCJS[39m [1mdist/WPET3HPL.cjs.map [22m[32m341.00 B[39m
|
|
82
|
-
[32mCJS[39m [1mdist/53OHF4EH.cjs.map [22m[32m214.00 B[39m
|
|
83
|
-
[32mCJS[39m [1mdist/asyncify.cjs.map [22m[32m73.00 B[39m
|
|
84
|
-
[32mCJS[39m [1mdist/2SJJDCZI.cjs.map [22m[32m719.00 B[39m
|
|
85
|
-
[32mCJS[39m [1mdist/deep.test-d.cjs.map [22m[32m1.47 KB[39m
|
|
86
|
-
[32mCJS[39m [1mdist/deep.cjs.map [22m[32m69.00 B[39m
|
|
87
|
-
[32mCJS[39m [1mdist/constructor.cjs.map [22m[32m76.00 B[39m
|
|
88
|
-
[32mCJS[39m [1mdist/branded.cjs.map [22m[32m72.00 B[39m
|
|
89
|
-
[32mCJS[39m [1mdist/identity.cjs.map [22m[32m73.00 B[39m
|
|
90
|
-
[32mCJS[39m [1mdist/24WEKBY3.cjs.map [22m[32m923.00 B[39m
|
|
91
|
-
[32mCJS[39m [1mdist/TVCGTTL5.cjs.map [22m[32m265.00 B[39m
|
|
92
|
-
[32mCJS[39m [1mdist/MLSONTXK.cjs.map [22m[32m780.00 B[39m
|
|
93
|
-
[32mCJS[39m [1mdist/disallowedAny.cjs.map [22m[32m78.00 B[39m
|
|
94
|
-
[32mCJS[39m [1mdist/574X5FJM.cjs.map [22m[32m390.00 B[39m
|
|
95
|
-
[32mCJS[39m [1mdist/strings.test-d.cjs.map [22m[32m1.70 KB[39m
|
|
96
|
-
[32mCJS[39m [1mdist/QXEVXGNQ.cjs.map [22m[32m762.74 KB[39m
|
|
97
|
-
[32mCJS[39m ⚡️ Build success in 2406ms
|
|
98
|
-
[32mESM[39m [1mdist/tuples.js [22m[32m117.00 B[39m
|
|
99
|
-
[32mESM[39m [1mdist/valueOf.js [22m[32m119.00 B[39m
|
|
100
|
-
[32mESM[39m [1mdist/viem.js [22m[32m113.00 B[39m
|
|
101
|
-
[32mESM[39m [1mdist/withRequired.js [22m[32m129.00 B[39m
|
|
102
|
-
[32mESM[39m [1mdist/GGKJNPTT.js [22m[32m42.15 KB[39m
|
|
103
|
-
[32mESM[39m [1mdist/TQNP6GIE.js [22m[32m158.00 B[39m
|
|
104
|
-
[32mESM[39m [1mdist/index.js [22m[32m558.00 B[39m
|
|
105
|
-
[32mESM[39m [1mdist/EM7SXG4B.js [22m[32m157.00 B[39m
|
|
106
|
-
[32mESM[39m [1mdist/62TVLGZP.js [22m[32m163.00 B[39m
|
|
107
|
-
[32mESM[39m [1mdist/J7BAXUWJ.js [22m[32m155.00 B[39m
|
|
108
|
-
[32mESM[39m [1mdist/KZQATXOW.js [22m[32m157.00 B[39m
|
|
109
|
-
[32mESM[39m [1mdist/lastOf.js [22m[32m117.00 B[39m
|
|
110
|
-
[32mESM[39m [1mdist/maybeUndefined.js [22m[32m133.00 B[39m
|
|
111
|
-
[32mESM[39m [1mdist/merge.js [22m[32m115.00 B[39m
|
|
112
|
-
[32mESM[39m [1mdist/Q6UBIYTZ.js [22m[32m165.00 B[39m
|
|
113
|
-
[32mESM[39m [1mdist/DDDCRYAA.js [22m[32m156.00 B[39m
|
|
114
|
-
[32mESM[39m [1mdist/methodOf.js [22m[32m121.00 B[39m
|
|
115
|
-
[32mESM[39m [1mdist/KEJFF7VD.js [22m[32m159.00 B[39m
|
|
116
|
-
[32mESM[39m [1mdist/removeNever.js [22m[32m127.00 B[39m
|
|
117
|
-
[32mESM[39m [1mdist/I5NXBMAF.js [22m[32m162.00 B[39m
|
|
118
|
-
[32mESM[39m [1mdist/strings.test-d.js [22m[32m745.00 B[39m
|
|
119
|
-
[32mESM[39m [1mdist/strings.js [22m[32m119.00 B[39m
|
|
120
|
-
[32mESM[39m [1mdist/CFTTK4D6.js [22m[32m165.00 B[39m
|
|
121
|
-
[32mESM[39m [1mdist/advancedRecord.js [22m[32m133.00 B[39m
|
|
122
|
-
[32mESM[39m [1mdist/B5GSIBEU.js [22m[32m158.00 B[39m
|
|
123
|
-
[32mESM[39m [1mdist/asyncify.js [22m[32m121.00 B[39m
|
|
124
|
-
[32mESM[39m [1mdist/TP4DJK6G.js [22m[32m159.00 B[39m
|
|
125
|
-
[32mESM[39m [1mdist/6IUBP3YE.js [22m[32m158.00 B[39m
|
|
126
|
-
[32mESM[39m [1mdist/constructor.js [22m[32m127.00 B[39m
|
|
127
|
-
[32mESM[39m [1mdist/deep.test-d.js [22m[32m491.00 B[39m
|
|
128
|
-
[32mESM[39m [1mdist/branded.js [22m[32m119.00 B[39m
|
|
129
|
-
[32mESM[39m [1mdist/deep.js [22m[32m113.00 B[39m
|
|
130
|
-
[32mESM[39m [1mdist/X6GYSLZB.js [22m[32m162.00 B[39m
|
|
131
|
-
[32mESM[39m [1mdist/FQ2L5NQU.js [22m[32m155.00 B[39m
|
|
132
|
-
[32mESM[39m [1mdist/V353KAGF.js [22m[32m164.00 B[39m
|
|
133
|
-
[32mESM[39m [1mdist/disallowedAny.js [22m[32m131.00 B[39m
|
|
134
|
-
[32mESM[39m [1mdist/identity.js [22m[32m121.00 B[39m
|
|
135
|
-
[32mESM[39m [1mdist/P3JODCMF.js [22m[32m159.00 B[39m
|
|
136
|
-
[32mESM[39m [1mdist/6AHA7PAZ.js [22m[32m1.87 KB[39m
|
|
137
|
-
[32mESM[39m [1mdist/QDQO2ODJ.js [22m[32m295.28 KB[39m
|
|
138
|
-
[32mESM[39m [1mdist/tuples.js.map [22m[32m70.00 B[39m
|
|
139
|
-
[32mESM[39m [1mdist/viem.js.map [22m[32m68.00 B[39m
|
|
140
|
-
[32mESM[39m [1mdist/valueOf.js.map [22m[32m71.00 B[39m
|
|
141
|
-
[32mESM[39m [1mdist/withRequired.js.map [22m[32m76.00 B[39m
|
|
142
|
-
[32mESM[39m [1mdist/GGKJNPTT.js.map [22m[32m100.16 KB[39m
|
|
143
|
-
[32mESM[39m [1mdist/TQNP6GIE.js.map [22m[32m517.00 B[39m
|
|
144
|
-
[32mESM[39m [1mdist/index.js.map [22m[32m644.00 B[39m
|
|
145
|
-
[32mESM[39m [1mdist/EM7SXG4B.js.map [22m[32m2.66 KB[39m
|
|
146
|
-
[32mESM[39m [1mdist/62TVLGZP.js.map [22m[32m278.00 B[39m
|
|
147
|
-
[32mESM[39m [1mdist/KZQATXOW.js.map [22m[32m638.00 B[39m
|
|
148
|
-
[32mESM[39m [1mdist/lastOf.js.map [22m[32m70.00 B[39m
|
|
149
|
-
[32mESM[39m [1mdist/J7BAXUWJ.js.map [22m[32m8.24 KB[39m
|
|
150
|
-
[32mESM[39m [1mdist/maybeUndefined.js.map [22m[32m78.00 B[39m
|
|
151
|
-
[32mESM[39m [1mdist/Q6UBIYTZ.js.map [22m[32m621.00 B[39m
|
|
152
|
-
[32mESM[39m [1mdist/merge.js.map [22m[32m69.00 B[39m
|
|
153
|
-
[32mESM[39m [1mdist/DDDCRYAA.js.map [22m[32m448.00 B[39m
|
|
154
|
-
[32mESM[39m [1mdist/methodOf.js.map [22m[32m72.00 B[39m
|
|
155
|
-
[32mESM[39m [1mdist/KEJFF7VD.js.map [22m[32m378.00 B[39m
|
|
156
|
-
[32mESM[39m [1mdist/removeNever.js.map [22m[32m75.00 B[39m
|
|
157
|
-
[32mESM[39m [1mdist/I5NXBMAF.js.map [22m[32m231.00 B[39m
|
|
158
|
-
[32mESM[39m [1mdist/strings.test-d.js.map [22m[32m1.68 KB[39m
|
|
159
|
-
[32mESM[39m [1mdist/strings.js.map [22m[32m71.00 B[39m
|
|
160
|
-
[32mESM[39m [1mdist/CFTTK4D6.js.map [22m[32m885.00 B[39m
|
|
161
|
-
[32mESM[39m [1mdist/advancedRecord.js.map [22m[32m78.00 B[39m
|
|
162
|
-
[32mESM[39m [1mdist/asyncify.js.map [22m[32m72.00 B[39m
|
|
163
|
-
[32mESM[39m [1mdist/TP4DJK6G.js.map [22m[32m320.00 B[39m
|
|
164
|
-
[32mESM[39m [1mdist/B5GSIBEU.js.map [22m[32m1.40 KB[39m
|
|
165
|
-
[32mESM[39m [1mdist/6IUBP3YE.js.map [22m[32m698.00 B[39m
|
|
166
|
-
[32mESM[39m [1mdist/constructor.js.map [22m[32m75.00 B[39m
|
|
167
|
-
[32mESM[39m [1mdist/deep.test-d.js.map [22m[32m1.45 KB[39m
|
|
168
|
-
[32mESM[39m [1mdist/deep.js.map [22m[32m68.00 B[39m
|
|
169
|
-
[32mESM[39m [1mdist/branded.js.map [22m[32m71.00 B[39m
|
|
170
|
-
[32mESM[39m [1mdist/X6GYSLZB.js.map [22m[32m193.00 B[39m
|
|
171
|
-
[32mESM[39m [1mdist/FQ2L5NQU.js.map [22m[32m759.00 B[39m
|
|
172
|
-
[32mESM[39m [1mdist/V353KAGF.js.map [22m[32m369.00 B[39m
|
|
173
|
-
[32mESM[39m [1mdist/identity.js.map [22m[32m72.00 B[39m
|
|
174
|
-
[32mESM[39m [1mdist/disallowedAny.js.map [22m[32m77.00 B[39m
|
|
175
|
-
[32mESM[39m [1mdist/P3JODCMF.js.map [22m[32m244.00 B[39m
|
|
176
|
-
[32mESM[39m [1mdist/6AHA7PAZ.js.map [22m[32m666.00 B[39m
|
|
177
|
-
[32mESM[39m [1mdist/QDQO2ODJ.js.map [22m[32m761.96 KB[39m
|
|
178
|
-
[32mESM[39m ⚡️ Build success in 2409ms
|
package/.turbo/turbo-lint.log
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @layerzerolabs/typescript-utils@0.0.0 lint /home/runner/work/monorepo-internal/monorepo-internal/packages/typescript-utils
|
|
3
|
-
> eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)
|
|
4
|
-
|
|
5
|
-
(node:67741) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/eslint.config.js?mtime=1775694520701 is not specified and it doesn't parse as CommonJS.
|
|
6
|
-
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
|
|
7
|
-
To eliminate this warning, add "type": "module" to /home/runner/work/monorepo-internal/monorepo-internal/package.json.
|
|
8
|
-
(Use `node --trace-warnings ...` to show where the warning was created)
|
package/src/advancedRecord.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export type AdvancedRecord<T = any, U = any> = {
|
|
2
|
-
readonly [key: string]: readonly [T, U];
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
export type DeepWritable<T> = { -readonly [P in keyof T]: DeepWritable<T[P]> };
|
|
6
|
-
|
|
7
|
-
export type AdvancedRecordLookup<
|
|
8
|
-
AR extends AdvancedRecord | undefined,
|
|
9
|
-
KeyToFind,
|
|
10
|
-
> = AR extends AdvancedRecord
|
|
11
|
-
? {
|
|
12
|
-
[P in keyof AR]: AR[P] extends readonly [infer K, infer V]
|
|
13
|
-
? // Distribute on K
|
|
14
|
-
K extends unknown
|
|
15
|
-
? KeyToFind extends DeepWritable<K>
|
|
16
|
-
? V
|
|
17
|
-
: DeepWritable<K> extends KeyToFind
|
|
18
|
-
? V
|
|
19
|
-
: never
|
|
20
|
-
: never
|
|
21
|
-
: never;
|
|
22
|
-
}[keyof AR]
|
|
23
|
-
: never;
|
package/src/asyncify.ts
DELETED
package/src/branded.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const tag = '___tag___';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a branded type of {@link T} with the brand {@link U}.
|
|
4
|
-
*
|
|
5
|
-
* @param T - Type to brand
|
|
6
|
-
* @param U - Label
|
|
7
|
-
* @returns Branded type
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* type Result = Branded<string, 'foo'>
|
|
11
|
-
* // ^? type Result = string & { [symbol]: 'foo' }
|
|
12
|
-
*/
|
|
13
|
-
export type Branded<T, U> = T & { [tag]: U };
|
|
14
|
-
/**
|
|
15
|
-
* Represents a percentage as a decimal value. For example, 25% is represented as 0.25
|
|
16
|
-
*/
|
|
17
|
-
export type Percent = number; // Branded<number, 'percent'>
|
|
18
|
-
|
|
19
|
-
export type BrandedError<T extends string> = Branded<Error, T>;
|
package/src/constructor.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type Constructor<T> = { new (...args: any[]): T };
|
package/src/deep.test-d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf, test } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import type { Branded } from './branded';
|
|
4
|
-
import type { DeepOptional } from './deep';
|
|
5
|
-
|
|
6
|
-
test('DeepOptional', () => {
|
|
7
|
-
// 1 level
|
|
8
|
-
type A = DeepOptional<{ a: string; b: number }>;
|
|
9
|
-
expectTypeOf<A>().toEqualTypeOf<{ a?: string; b?: number }>();
|
|
10
|
-
|
|
11
|
-
// 2 levels
|
|
12
|
-
type B = DeepOptional<{ a: { c: string }; b: number }>;
|
|
13
|
-
expectTypeOf<B>().toEqualTypeOf<{ a?: { c?: string }; b?: number }>();
|
|
14
|
-
|
|
15
|
-
// 1 level with brand tag
|
|
16
|
-
type obj = { a: string; b: number };
|
|
17
|
-
type branded = Branded<obj, 'foo'>;
|
|
18
|
-
type C = DeepOptional<branded>;
|
|
19
|
-
expectTypeOf<C>().toEqualTypeOf<{ a?: string; b?: number; ___tag___: 'foo' }>();
|
|
20
|
-
|
|
21
|
-
// 2 levels with brand tag
|
|
22
|
-
type obj2 = { a: branded; b: number };
|
|
23
|
-
type D = DeepOptional<Branded<obj2, 'foo2'>>;
|
|
24
|
-
expectTypeOf<D>().toEqualTypeOf<{
|
|
25
|
-
a?: {
|
|
26
|
-
a?: string;
|
|
27
|
-
b?: number;
|
|
28
|
-
___tag___: 'foo';
|
|
29
|
-
};
|
|
30
|
-
b?: number;
|
|
31
|
-
___tag___: 'foo2';
|
|
32
|
-
}>();
|
|
33
|
-
});
|
package/src/deep.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Prettify } from './viem';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Copy the brand tag from the branded.ts file, can't import it to keep it hidden from library users
|
|
5
|
-
*/
|
|
6
|
-
const brandTag = '___tag___';
|
|
7
|
-
|
|
8
|
-
export type DeepRequire<T> = {
|
|
9
|
-
[P in keyof T]-?: DeepRequire<T[P]>;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type DeepOptional<T> = T extends { [brandTag]: infer V }
|
|
13
|
-
? Prettify<
|
|
14
|
-
{ [brandTag]: V } & {
|
|
15
|
-
[P in keyof T]?: DeepOptional<T[P]>;
|
|
16
|
-
}
|
|
17
|
-
>
|
|
18
|
-
: {
|
|
19
|
-
[P in keyof T]?: DeepOptional<T[P]>;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type DeepUnion<T, U> =
|
|
23
|
-
| {
|
|
24
|
-
[P in keyof T]: DeepUnion<T[P], U>;
|
|
25
|
-
}
|
|
26
|
-
| U;
|
package/src/disallowedAny.ts
DELETED
package/src/identity.ts
DELETED
package/src/index.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './advancedRecord';
|
|
2
|
-
export * from './asyncify';
|
|
3
|
-
export * from './branded';
|
|
4
|
-
export * from './constructor';
|
|
5
|
-
export * from './deep';
|
|
6
|
-
export * from './disallowedAny';
|
|
7
|
-
export * from './identity';
|
|
8
|
-
export * from './lastOf';
|
|
9
|
-
export * from './maybeUndefined';
|
|
10
|
-
export * from './merge';
|
|
11
|
-
export * from './methodOf';
|
|
12
|
-
export * from './removeNever';
|
|
13
|
-
export * from './strings';
|
|
14
|
-
export * from './tuples';
|
|
15
|
-
export * from './valueOf';
|
|
16
|
-
export * from './viem';
|
|
17
|
-
export * from './withRequired';
|
package/src/lastOf.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
|
|
2
|
-
k: infer I,
|
|
3
|
-
) => void
|
|
4
|
-
? I
|
|
5
|
-
: never;
|
|
6
|
-
|
|
7
|
-
export type LastOf<T> =
|
|
8
|
-
UnionToIntersection<T extends any ? () => T : never> extends () => infer R ? R : never;
|
|
9
|
-
|
|
10
|
-
type Prepend<T, U extends any[]> = [T, ...U];
|
|
11
|
-
|
|
12
|
-
export type UnionToArray<T, U extends any[] = []> =
|
|
13
|
-
LastOf<T> extends never ? U : UnionToArray<Exclude<T, LastOf<T>>, Prepend<LastOf<T>, U>>;
|
|
14
|
-
|
|
15
|
-
export type RestOf<T> = Exclude<T, LastOf<T>>;
|
package/src/maybeUndefined.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description Maps the result type `R` to `R | undefined` when the input type `T` includes `undefined`,
|
|
3
|
-
* preserving the undefined-ness of the input in the output type.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* MaybeUndefinedMapped<string | undefined, number>
|
|
7
|
-
* => number | undefined
|
|
8
|
-
*
|
|
9
|
-
* MaybeUndefinedMapped<string, number>
|
|
10
|
-
* => number
|
|
11
|
-
*/
|
|
12
|
-
export type MaybeUndefinedMapped<T, R> = undefined extends T
|
|
13
|
-
? T extends undefined
|
|
14
|
-
? undefined
|
|
15
|
-
: R | undefined
|
|
16
|
-
: R;
|
package/src/merge.ts
DELETED
package/src/methodOf.ts
DELETED
package/src/removeNever.ts
DELETED
package/src/strings.test-d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { expectTypeOf, test } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import type { HexStringIsTrimmed, StringWithoutSuffix } from './strings';
|
|
4
|
-
|
|
5
|
-
test('StringWithoutSuffix', () => {
|
|
6
|
-
type A = StringWithoutSuffix<'hello', 'world'>;
|
|
7
|
-
expectTypeOf<A>().toBeString();
|
|
8
|
-
|
|
9
|
-
type B = StringWithoutSuffix<'hello', 'lo'>;
|
|
10
|
-
expectTypeOf<B>().toBeNever();
|
|
11
|
-
|
|
12
|
-
// Multiple suffixes test:
|
|
13
|
-
type C = StringWithoutSuffix<'hello', 'lo' | 'world'>;
|
|
14
|
-
expectTypeOf<C>().toBeNever();
|
|
15
|
-
|
|
16
|
-
type D = StringWithoutSuffix<'hello world', 'lo' | 'world'>;
|
|
17
|
-
expectTypeOf<D>().toBeNever();
|
|
18
|
-
|
|
19
|
-
type E = StringWithoutSuffix<'hello world!', 'lo' | 'world'>;
|
|
20
|
-
expectTypeOf<E>().toBeString();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
test('HexStringIsTrimmed', () => {
|
|
24
|
-
type A = HexStringIsTrimmed<'0x0'>;
|
|
25
|
-
expectTypeOf<A>().toExtend<true>();
|
|
26
|
-
|
|
27
|
-
type B = HexStringIsTrimmed<'0x00'>;
|
|
28
|
-
expectTypeOf<B>().toExtend<false>();
|
|
29
|
-
|
|
30
|
-
type C = HexStringIsTrimmed<'0x'>;
|
|
31
|
-
expectTypeOf<C>().toExtend<false>();
|
|
32
|
-
});
|
package/src/strings.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { Branded } from './branded';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Guarantees that a string does not end with a suffix.
|
|
5
|
-
* You can remove multiple suffixes by using a union.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* type A = StringWithoutSuffix<'hello', 'world'>; // 'hello'
|
|
9
|
-
* type B = StringWithoutSuffix<'hello', 'lo'>; // never
|
|
10
|
-
* type C = StringWithoutSuffix<'hello world', 'lo' | 'world'>; // never
|
|
11
|
-
*/
|
|
12
|
-
export type StringWithoutSuffix<
|
|
13
|
-
T extends string,
|
|
14
|
-
Suffix extends string,
|
|
15
|
-
> = T extends `${infer _}${Suffix}` ? never : T;
|
|
16
|
-
|
|
17
|
-
export type HexString = `0x${string}`;
|
|
18
|
-
|
|
19
|
-
export declare const _NormalizedHexString: unique symbol;
|
|
20
|
-
|
|
21
|
-
export type NormalizedHexString = Branded<typeof _NormalizedHexString, 'NormalizedHexString'>;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Guarantees that a hex string is trimmed.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* type A = HexStringIsTrimmed<'0x0'>; // true
|
|
28
|
-
* type B = HexStringIsTrimmed<'0x00'>; // false
|
|
29
|
-
* type C = HexStringIsTrimmed<'0x'>; // false
|
|
30
|
-
* type D = HexStringIsTrimmed<'0x100'>; // true
|
|
31
|
-
*/
|
|
32
|
-
export type HexStringIsTrimmed<T extends HexString> = T extends '0x0'
|
|
33
|
-
? true
|
|
34
|
-
: T extends '0x'
|
|
35
|
-
? false
|
|
36
|
-
: T extends `0x0${string}`
|
|
37
|
-
? false
|
|
38
|
-
: true;
|
|
39
|
-
|
|
40
|
-
export declare const _NumberString: unique symbol;
|
|
41
|
-
|
|
42
|
-
export type DecimalString = Branded<typeof _NumberString, 'DecimalString'>;
|
package/src/tuples.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { BrandedError } from './branded';
|
|
2
|
-
|
|
3
|
-
//check that the tuple T uses every type in the union K at least once
|
|
4
|
-
export type IsComplete<
|
|
5
|
-
T extends readonly (string | number | symbol)[],
|
|
6
|
-
K extends string | number | symbol,
|
|
7
|
-
> = Exclude<K, T[number]> extends never ? true : false;
|
|
8
|
-
|
|
9
|
-
export type TryGetDuplicate<
|
|
10
|
-
T extends readonly (string | number | symbol)[],
|
|
11
|
-
Seen extends (string | number | symbol)[] = [],
|
|
12
|
-
> = T extends [infer Head, ...infer Tail]
|
|
13
|
-
? Head extends Seen[number]
|
|
14
|
-
? Head
|
|
15
|
-
: Head extends string | number | symbol
|
|
16
|
-
? Tail extends readonly (string | number | symbol)[]
|
|
17
|
-
? TryGetDuplicate<Tail, [...Seen, Head]>
|
|
18
|
-
: false
|
|
19
|
-
: false
|
|
20
|
-
: false;
|
|
21
|
-
|
|
22
|
-
//check that the tuple T is a valid ordering of AllKeys, using IsComplete and TryGetDuplicate
|
|
23
|
-
//returns a branded error if there are missing keys or duplicates
|
|
24
|
-
export type AssertUniqueCompleteSet<
|
|
25
|
-
T extends readonly (string | number | symbol)[],
|
|
26
|
-
AllKeys extends string | number | symbol,
|
|
27
|
-
> =
|
|
28
|
-
IsComplete<T, AllKeys> extends false
|
|
29
|
-
? BrandedError<`Missing key: ${Exclude<AllKeys extends Symbol ? 'ERR' : AllKeys, T[number]>}`>
|
|
30
|
-
: TryGetDuplicate<T> extends false
|
|
31
|
-
? T
|
|
32
|
-
: BrandedError<`Duplicate key found: ${TryGetDuplicate<T>}`>;
|
|
33
|
-
|
|
34
|
-
type BuildTupleHelper<
|
|
35
|
-
Element,
|
|
36
|
-
Length extends number,
|
|
37
|
-
Rest extends Element[],
|
|
38
|
-
> = Rest['length'] extends Length
|
|
39
|
-
? readonly [...Rest] // Terminate with readonly array (aka tuple)
|
|
40
|
-
: BuildTupleHelper<Element, Length, [Element, ...Rest]>;
|
|
41
|
-
|
|
42
|
-
export type BuildTuple<Element, Length extends number> = number extends Length
|
|
43
|
-
? // Because `Length extends number` and `number extends Length`, then `Length` is not a specific finite number.
|
|
44
|
-
readonly Element[] // It's not fixed length.
|
|
45
|
-
: BuildTupleHelper<Element, Length, []>; // Otherwise it is a fixed length tuple.
|
|
46
|
-
|
|
47
|
-
export type TuplesToObject<T extends readonly (readonly [PropertyKey, any])[]> = {
|
|
48
|
-
[K in T[number] as K[0]]: K[1];
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export type TuplePrefixUnion<T extends any[]> =
|
|
52
|
-
| []
|
|
53
|
-
| (Required<T> extends [...infer Init, any] ? Required<T> | TuplePrefixUnion<Init> : never);
|
|
54
|
-
|
|
55
|
-
export type SubtractTuple<Minuend extends any[], Subtrahend extends any[]> = Subtrahend extends [
|
|
56
|
-
any,
|
|
57
|
-
...infer S,
|
|
58
|
-
]
|
|
59
|
-
? Minuend extends [any, ...infer M]
|
|
60
|
-
? // keep subtracting
|
|
61
|
-
SubtractTuple<M, S>
|
|
62
|
-
: // subtrahend has a cardinality less than minuend
|
|
63
|
-
never
|
|
64
|
-
: // we fully subtracted already
|
|
65
|
-
Minuend;
|
package/src/valueOf.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export type IntersectionValueOf<T> = (
|
|
2
|
-
T[keyof T] extends infer U ? (U extends any ? (x: U) => void : never) : never
|
|
3
|
-
) extends (x: infer I) => void
|
|
4
|
-
? I
|
|
5
|
-
: never;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @description Creates a type that extracts the values of T.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ValueOf<{ a: string, b: number }>
|
|
12
|
-
* => string | number
|
|
13
|
-
*
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export type ValueOf<T> = T[keyof T];
|
package/src/viem.ts
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Filters out all members of {@link T} that are not {@link P}
|
|
3
|
-
*
|
|
4
|
-
* @param T - Items to filter
|
|
5
|
-
* @param P - Type to filter out
|
|
6
|
-
* @returns Filtered items
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* type Result = Filter<['a', 'b', 'c'], 'b'>
|
|
10
|
-
* // ^? type Result = ['a', 'c']
|
|
11
|
-
*/
|
|
12
|
-
export type Filter<
|
|
13
|
-
T extends readonly unknown[],
|
|
14
|
-
P,
|
|
15
|
-
Acc extends readonly unknown[] = [],
|
|
16
|
-
> = T extends readonly [infer F, ...infer Rest extends readonly unknown[]]
|
|
17
|
-
? [F] extends [P]
|
|
18
|
-
? Filter<Rest, P, [...Acc, F]>
|
|
19
|
-
: Filter<Rest, P, Acc>
|
|
20
|
-
: readonly [...Acc];
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* @description Checks if {@link T} can be narrowed further than {@link U}
|
|
24
|
-
* @param T - Type to check
|
|
25
|
-
* @param U - Type to compare against
|
|
26
|
-
* @example
|
|
27
|
-
* type Result = IsNarrowable<'foo', string>
|
|
28
|
-
* // ^? true
|
|
29
|
-
*/
|
|
30
|
-
export type IsNarrowable<T, U> =
|
|
31
|
-
IsNever<(T extends U ? true : false) & (U extends T ? false : true)> extends true
|
|
32
|
-
? false
|
|
33
|
-
: true;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @description Checks if {@link T} is `never`
|
|
37
|
-
* @param T - Type to check
|
|
38
|
-
* @example
|
|
39
|
-
* type Result = IsNever<never>
|
|
40
|
-
* // ^? type Result = true
|
|
41
|
-
*/
|
|
42
|
-
export type IsNever<T> = [T] extends [never] ? true : false;
|
|
43
|
-
|
|
44
|
-
/** Removes `readonly` from all properties of an object. */
|
|
45
|
-
export type Mutable<type extends object> = {
|
|
46
|
-
-readonly [key in keyof type]: type[key];
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @description Evaluates boolean "or" condition for {@link T} properties.
|
|
51
|
-
* @param T - Type to check
|
|
52
|
-
*
|
|
53
|
-
* * @example
|
|
54
|
-
* type Result = Or<[false, true, false]>
|
|
55
|
-
* // ^? type Result = true
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* type Result = Or<[false, false, false]>
|
|
59
|
-
* // ^? type Result = false
|
|
60
|
-
*/
|
|
61
|
-
export type Or<T extends readonly unknown[]> = T extends readonly [infer Head, ...infer Tail]
|
|
62
|
-
? Head extends true
|
|
63
|
-
? true
|
|
64
|
-
: Or<Tail>
|
|
65
|
-
: false;
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @description Checks if {@link T} is `undefined`
|
|
69
|
-
* @param T - Type to check
|
|
70
|
-
* @example
|
|
71
|
-
* type Result = IsUndefined<undefined>
|
|
72
|
-
* // ^? type Result = true
|
|
73
|
-
*/
|
|
74
|
-
export type IsUndefined<T> = [undefined] extends [T] ? true : false;
|
|
75
|
-
|
|
76
|
-
export type MaybePromise<T> = T | Promise<T>;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* @description Makes attributes on the type T required if required is true.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* MaybeRequired<{ a: string, b?: number }, true>
|
|
83
|
-
* => { a: string, b: number }
|
|
84
|
-
*
|
|
85
|
-
* MaybeRequired<{ a: string, b?: number }, false>
|
|
86
|
-
* => { a: string, b?: number }
|
|
87
|
-
*/
|
|
88
|
-
export type MaybeRequired<T, required extends boolean> = required extends true
|
|
89
|
-
? ExactRequired<T>
|
|
90
|
-
: T;
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* @description Assigns the properties of U onto T.
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* Assign<{ a: string, b: number }, { a: undefined, c: boolean }>
|
|
97
|
-
* => { a: undefined, b: number, c: boolean }
|
|
98
|
-
*/
|
|
99
|
-
export type Assign<T, U> = Assign_<T, U> & U;
|
|
100
|
-
type Assign_<T, U> = {
|
|
101
|
-
[K in keyof T as K extends keyof U ? (U[K] extends void ? never : K) : K]: K extends keyof U
|
|
102
|
-
? U[K]
|
|
103
|
-
: T[K];
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
// TODO: Remove when peer dep `typescript@>=4.5` (NoInfer is native)
|
|
107
|
-
export type NoInfer<type> = [type][type extends any ? 0 : never];
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* @description Constructs a type by excluding `undefined` from `T`.
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* NoUndefined<string | undefined>
|
|
114
|
-
* => string
|
|
115
|
-
*
|
|
116
|
-
* @internal
|
|
117
|
-
*/
|
|
118
|
-
export type NoUndefined<T> = T extends undefined ? never : T;
|
|
119
|
-
|
|
120
|
-
/** Strict version of built-in Omit type */
|
|
121
|
-
export type Omit<type, keys extends keyof type> = Pick<type, Exclude<keyof type, keys>>;
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* @description Creates a type that is a partial of T, but with the required keys K.
|
|
125
|
-
*
|
|
126
|
-
* @example
|
|
127
|
-
* PartialBy<{ a: string, b: number }, 'a'>
|
|
128
|
-
* => { a?: string, b: number }
|
|
129
|
-
*/
|
|
130
|
-
export type PartialBy<T, K extends keyof T> = Omit<T, K> & ExactPartial<Pick<T, K>>;
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @description Combines members of an intersection into a readable type.
|
|
134
|
-
*
|
|
135
|
-
* @see {@link https://twitter.com/mattpocockuk/status/1622730173446557697?s=20&t=NdpAcmEFXY01xkqU3KO0Mg}
|
|
136
|
-
* @example
|
|
137
|
-
* Prettify<{ a: string } & { b: string } & { c: number, d: bigint }>
|
|
138
|
-
* => { a: string, b: string, c: number, d: bigint }
|
|
139
|
-
*/
|
|
140
|
-
export type Prettify<T> = {
|
|
141
|
-
[K in keyof T]: T[K];
|
|
142
|
-
} & {};
|
|
143
|
-
|
|
144
|
-
/** @internal */
|
|
145
|
-
export type Evaluate<type> = {
|
|
146
|
-
[key in keyof type]: type[key];
|
|
147
|
-
} & {};
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* @description Creates a type that is T with the required keys K.
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* RequiredBy<{ a?: string, b: number }, 'a'>
|
|
154
|
-
* => { a: string, b: number }
|
|
155
|
-
*/
|
|
156
|
-
export type RequiredBy<T, K extends keyof T> = Omit<T, K> & ExactRequired<Pick<T, K>>;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* @description Returns truthy if `array` contains `value`.
|
|
160
|
-
*
|
|
161
|
-
* @example
|
|
162
|
-
* Some<[1, 2, 3], 2>
|
|
163
|
-
* => true
|
|
164
|
-
*/
|
|
165
|
-
export type Some<array extends readonly unknown[], value> = array extends readonly [
|
|
166
|
-
value,
|
|
167
|
-
...unknown[],
|
|
168
|
-
]
|
|
169
|
-
? true
|
|
170
|
-
: array extends readonly [unknown, ...infer rest]
|
|
171
|
-
? Some<rest, value>
|
|
172
|
-
: false;
|
|
173
|
-
|
|
174
|
-
export type UnionToTuple<
|
|
175
|
-
union,
|
|
176
|
-
///
|
|
177
|
-
last = LastInUnion<union>,
|
|
178
|
-
> = [union] extends [never] ? [] : [...UnionToTuple<Exclude<union, last>>, last];
|
|
179
|
-
type LastInUnion<U> =
|
|
180
|
-
UnionToIntersection<U extends unknown ? (x: U) => 0 : never> extends (x: infer l) => 0
|
|
181
|
-
? l
|
|
182
|
-
: never;
|
|
183
|
-
type UnionToIntersection<union> = (union extends unknown ? (arg: union) => 0 : never) extends (
|
|
184
|
-
arg: infer i,
|
|
185
|
-
) => 0
|
|
186
|
-
? i
|
|
187
|
-
: never;
|
|
188
|
-
|
|
189
|
-
export type IsUnion<
|
|
190
|
-
union,
|
|
191
|
-
///
|
|
192
|
-
union2 = union,
|
|
193
|
-
> = union extends union2 ? ([union2] extends [union] ? false : true) : never;
|
|
194
|
-
|
|
195
|
-
export type MaybePartial<type, enabled extends boolean | undefined> = enabled extends true
|
|
196
|
-
? Prettify<ExactPartial<type>>
|
|
197
|
-
: type;
|
|
198
|
-
|
|
199
|
-
export type ExactPartial<type> = {
|
|
200
|
-
[key in keyof type]?: type[key] | undefined;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
export type ExactRequired<type> = {
|
|
204
|
-
[P in keyof type]-?: Exclude<type[P], undefined>;
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
export type OneOf<
|
|
208
|
-
union extends object,
|
|
209
|
-
fallback extends object | undefined = undefined,
|
|
210
|
-
///
|
|
211
|
-
keys extends KeyofUnion<union> = KeyofUnion<union>,
|
|
212
|
-
> = union extends infer item
|
|
213
|
-
? Prettify<
|
|
214
|
-
item & {
|
|
215
|
-
[key in Exclude<keys, keyof item>]?: fallback extends object
|
|
216
|
-
? key extends keyof fallback
|
|
217
|
-
? fallback[key]
|
|
218
|
-
: undefined
|
|
219
|
-
: undefined;
|
|
220
|
-
}
|
|
221
|
-
>
|
|
222
|
-
: never;
|
|
223
|
-
type KeyofUnion<type> = type extends type ? keyof type : never;
|
|
224
|
-
|
|
225
|
-
///////////////////////////////////////////////////////////////////////////
|
|
226
|
-
// Loose types
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* Loose version of {@link Omit}
|
|
230
|
-
* @internal
|
|
231
|
-
*/
|
|
232
|
-
export type LooseOmit<type, keys extends string> = Pick<type, Exclude<keyof type, keys>>;
|
|
233
|
-
|
|
234
|
-
///////////////////////////////////////////////////////////////////////////
|
|
235
|
-
// Union types
|
|
236
|
-
|
|
237
|
-
export type UnionEvaluate<type> = type extends object ? Prettify<type> : type;
|
|
238
|
-
|
|
239
|
-
export type UnionLooseOmit<type, keys extends string> = type extends any
|
|
240
|
-
? LooseOmit<type, keys>
|
|
241
|
-
: never;
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* @description Construct a type with the properties of union type T except for those in type K.
|
|
245
|
-
* @example
|
|
246
|
-
* type Result = UnionOmit<{ a: string, b: number } | { a: string, b: undefined, c: number }, 'a'>
|
|
247
|
-
* => { b: number } | { b: undefined, c: number }
|
|
248
|
-
*/
|
|
249
|
-
export type UnionOmit<type, keys extends keyof type> = type extends any ? Omit<type, keys> : never;
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* @description Construct a type with the properties of union type T except for those in type K.
|
|
253
|
-
* @example
|
|
254
|
-
* type Result = UnionOmit<{ a: string, b: number } | { a: string, b: undefined, c: number }, 'a'>
|
|
255
|
-
* => { b: number } | { b: undefined, c: number }
|
|
256
|
-
*/
|
|
257
|
-
export type UnionPick<type, keys extends keyof type> = type extends any ? Pick<type, keys> : never;
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* @description Creates a type that is a partial of T, but with the required keys K.
|
|
261
|
-
*
|
|
262
|
-
* @example
|
|
263
|
-
* PartialBy<{ a: string, b: number } | { a: string, b: undefined, c: number }, 'a'>
|
|
264
|
-
* => { a?: string, b: number } | { a?: string, b: undefined, c: number }
|
|
265
|
-
*/
|
|
266
|
-
export type UnionPartialBy<T, K extends keyof T> = T extends any ? PartialBy<T, K> : never;
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* @description Creates a type that is T with the required keys K.
|
|
270
|
-
*
|
|
271
|
-
* @example
|
|
272
|
-
* RequiredBy<{ a?: string, b: number } | { a?: string, c?: number }, 'a'>
|
|
273
|
-
* => { a: string, b: number } | { a: string, c?: number }
|
|
274
|
-
*/
|
|
275
|
-
export type UnionRequiredBy<T, K extends keyof T> = T extends any ? RequiredBy<T, K> : never;
|
package/src/withRequired.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { describe, expectTypeOf, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import type { DisallowedAny } from '../src/disallowedAny';
|
|
4
|
-
|
|
5
|
-
describe('DisallowedAny type utility', () => {
|
|
6
|
-
it('disallows bare any', () => {
|
|
7
|
-
type R = DisallowedAny<any>;
|
|
8
|
-
expectTypeOf<R>().toEqualTypeOf<never>();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('passes through primitives', () => {
|
|
12
|
-
expectTypeOf<DisallowedAny<string>>().toEqualTypeOf<string>();
|
|
13
|
-
expectTypeOf<DisallowedAny<number>>().toEqualTypeOf<number>();
|
|
14
|
-
expectTypeOf<DisallowedAny<boolean>>().toEqualTypeOf<boolean>();
|
|
15
|
-
expectTypeOf<DisallowedAny<symbol>>().toEqualTypeOf<symbol>();
|
|
16
|
-
expectTypeOf<DisallowedAny<bigint>>().toEqualTypeOf<bigint>();
|
|
17
|
-
expectTypeOf<DisallowedAny<null>>().toEqualTypeOf<null>();
|
|
18
|
-
expectTypeOf<DisallowedAny<undefined>>().toEqualTypeOf<undefined>();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it('does not treat unknown as any', () => {
|
|
22
|
-
expectTypeOf<DisallowedAny<unknown>>().toEqualTypeOf<unknown>();
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it('disallows unions that include any (any absorbs the union)', () => {
|
|
26
|
-
type U1 = DisallowedAny<any | string>;
|
|
27
|
-
expectTypeOf<U1>().toEqualTypeOf<never>();
|
|
28
|
-
|
|
29
|
-
type U2 = DisallowedAny<string | number>;
|
|
30
|
-
expectTypeOf<U2>().toEqualTypeOf<string | number>();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('disallows intersections that include any (any absorbs the intersection)', () => {
|
|
34
|
-
type I1 = DisallowedAny<any & { a: 1 }>;
|
|
35
|
-
expectTypeOf<I1>().toEqualTypeOf<never>();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('works with generics: when T is any it becomes never; otherwise it passes through', () => {
|
|
39
|
-
type Wrap<T> = DisallowedAny<T>;
|
|
40
|
-
|
|
41
|
-
type G1 = Wrap<any>;
|
|
42
|
-
expectTypeOf<G1>().toEqualTypeOf<never>();
|
|
43
|
-
|
|
44
|
-
type G2 = Wrap<{ x: string }>; // non-any generic
|
|
45
|
-
expectTypeOf<G2>().toEqualTypeOf<{ x: string }>();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it('allows type constraints', () => {
|
|
49
|
-
const myFunc = <T extends number>(_: DisallowedAny<T>): void => {};
|
|
50
|
-
myFunc(5);
|
|
51
|
-
//@ts-expect-error
|
|
52
|
-
myFunc(5 as any);
|
|
53
|
-
});
|
|
54
|
-
});
|
package/test/merge.test.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { describe, expectTypeOf, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import type { Merge } from '../src/merge';
|
|
4
|
-
|
|
5
|
-
describe('Merge type utility', () => {
|
|
6
|
-
it('should handle empty object edge cases correctly', () => {
|
|
7
|
-
// Test the main fix: empty objects should be handled properly
|
|
8
|
-
type EmptyLeftMerge = Merge<{}, { a: string; b: number }>;
|
|
9
|
-
expectTypeOf<EmptyLeftMerge>().toEqualTypeOf<{ a: string; b: number }>();
|
|
10
|
-
|
|
11
|
-
type EmptyRightMerge = Merge<{ a: string; b: number }, {}>;
|
|
12
|
-
expectTypeOf<EmptyRightMerge>().toEqualTypeOf<{ a: string; b: number }>();
|
|
13
|
-
|
|
14
|
-
type BothEmptyMerge = Merge<{}, {}>;
|
|
15
|
-
expectTypeOf<BothEmptyMerge>().toEqualTypeOf<{}>();
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('should merge types correctly for non-empty objects', () => {
|
|
19
|
-
// Basic functionality should still work
|
|
20
|
-
type BasicMerge = Merge<{ a: string }, { b: number }>;
|
|
21
|
-
expectTypeOf<BasicMerge>().toEqualTypeOf<{ a: string; b: number }>();
|
|
22
|
-
|
|
23
|
-
// Property override should work
|
|
24
|
-
type OverrideMerge = Merge<{ a: string; b: string }, { b: number; c: boolean }>;
|
|
25
|
-
expectTypeOf<OverrideMerge>().toEqualTypeOf<{ a: string; b: number; c: boolean }>();
|
|
26
|
-
});
|
|
27
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@layerzerolabs/typescript-configuration/tsconfig.base.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "./src",
|
|
5
|
-
"outDir": "./dist",
|
|
6
|
-
"strictPropertyInitialization": false,
|
|
7
|
-
"noUnusedLocals": false,
|
|
8
|
-
"noUnusedParameters": false,
|
|
9
|
-
"jsx": "react-jsx"
|
|
10
|
-
},
|
|
11
|
-
"exclude": [
|
|
12
|
-
"node_modules",
|
|
13
|
-
"**/__mocks__/*",
|
|
14
|
-
"**/__tests__/*",
|
|
15
|
-
"**/*.spec.ts",
|
|
16
|
-
"**/*.test.ts",
|
|
17
|
-
"dist"
|
|
18
|
-
],
|
|
19
|
-
"include": ["src/**/*"]
|
|
20
|
-
}
|