@layerzerolabs/typescript-utils 0.0.45 → 0.0.46
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/.turbo/turbo-build.log +82 -74
- package/dist/{EXZ6DAVW.js → 7MFOZW3L.js} +2 -2
- package/dist/{EXZ6DAVW.js.map → 7MFOZW3L.js.map} +1 -1
- package/dist/KLAVEBFH.cjs +8438 -0
- package/dist/KLAVEBFH.cjs.map +1 -0
- package/dist/{OQCEYCFE.cjs → KLHW5WN3.cjs} +2 -2
- package/dist/{OQCEYCFE.cjs.map → KLHW5WN3.cjs.map} +1 -1
- package/dist/{PUPSLF67.cjs → LJLAUEED.cjs} +2 -2
- package/dist/LJLAUEED.cjs.map +1 -0
- package/dist/OV67BGO6.js +8435 -0
- package/dist/OV67BGO6.js.map +1 -0
- package/dist/{H4XPUNCM.js → X43TXNZ3.js} +2 -2
- package/dist/X43TXNZ3.js.map +1 -0
- package/dist/deep.cjs +1 -1
- package/dist/deep.d.ts +13 -1
- package/dist/deep.d.ts.map +1 -1
- package/dist/deep.js +1 -1
- package/dist/deep.test-d.cjs +15 -0
- package/dist/deep.test-d.cjs.map +1 -0
- package/dist/deep.test-d.d.ts +2 -0
- package/dist/deep.test-d.d.ts.map +1 -0
- package/dist/deep.test-d.js +13 -0
- package/dist/deep.test-d.js.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/dist/strings.cjs +1 -1
- package/dist/strings.d.ts +2 -2
- package/dist/strings.d.ts.map +1 -1
- package/dist/strings.js +1 -1
- package/dist/strings.test-d.cjs +11 -8442
- package/dist/strings.test-d.cjs.map +1 -1
- package/dist/strings.test-d.js +4 -8435
- package/dist/strings.test-d.js.map +1 -1
- package/package.json +3 -3
- package/src/deep.test-d.ts +33 -0
- package/src/deep.ts +16 -3
- package/src/strings.ts +2 -2
- package/dist/H4XPUNCM.js.map +0 -1
- package/dist/PUPSLF67.cjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/typescript-utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"tsup": "^8.4.0",
|
|
18
18
|
"vitest": "^3.2.3",
|
|
19
|
-
"@layerzerolabs/tsup-configuration": "0.0.
|
|
20
|
-
"@layerzerolabs/typescript-configuration": "0.0.
|
|
19
|
+
"@layerzerolabs/tsup-configuration": "0.0.46",
|
|
20
|
+
"@layerzerolabs/typescript-configuration": "0.0.46"
|
|
21
21
|
},
|
|
22
22
|
"publishConfig": {
|
|
23
23
|
"access": "restricted",
|
|
@@ -0,0 +1,33 @@
|
|
|
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
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
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
|
+
|
|
1
8
|
export type DeepRequire<T> = {
|
|
2
9
|
[P in keyof T]-?: DeepRequire<T[P]>;
|
|
3
10
|
};
|
|
4
11
|
|
|
5
|
-
export type DeepOptional<T> = {
|
|
6
|
-
|
|
7
|
-
}
|
|
12
|
+
export type DeepOptional<T> = T extends { [brandTag]: infer U }
|
|
13
|
+
? Prettify<
|
|
14
|
+
{ [brandTag]: U } & {
|
|
15
|
+
[P in keyof T]?: DeepOptional<T[P]>;
|
|
16
|
+
}
|
|
17
|
+
>
|
|
18
|
+
: {
|
|
19
|
+
[P in keyof T]?: DeepOptional<T[P]>;
|
|
20
|
+
};
|
package/src/strings.ts
CHANGED
|
@@ -37,6 +37,6 @@ export type HexStringIsTrimmed<T extends HexString> = T extends '0x0'
|
|
|
37
37
|
? false
|
|
38
38
|
: true;
|
|
39
39
|
|
|
40
|
-
export declare const
|
|
40
|
+
export declare const _NumberString: unique symbol;
|
|
41
41
|
|
|
42
|
-
export type DecimalString = Branded<typeof
|
|
42
|
+
export type DecimalString = Branded<typeof _NumberString, 'DecimalString'>;
|
package/dist/H4XPUNCM.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/deep.ts"],"names":[],"mappings":";;;AAIA,cAAA,EAAA","file":"H4XPUNCM.js","sourcesContent":["export type DeepRequire<T> = {\n [P in keyof T]-?: DeepRequire<T[P]>;\n};\n\nexport type DeepOptional<T> = {\n [P in keyof T]?: DeepOptional<T[P]>;\n};\n"]}
|
package/dist/PUPSLF67.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/deep.ts"],"names":["init_cjs_shims"],"mappings":";;;;;AAIAA,2BAAA,EAAA","file":"PUPSLF67.cjs","sourcesContent":["export type DeepRequire<T> = {\n [P in keyof T]-?: DeepRequire<T[P]>;\n};\n\nexport type DeepOptional<T> = {\n [P in keyof T]?: DeepOptional<T[P]>;\n};\n"]}
|