pwi-plata-type 0.4.207 → 0.4.209
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
CHANGED
package/src/@types/global.d.ts
CHANGED
|
@@ -113,7 +113,9 @@ interface PlataEnvConfig {
|
|
|
113
113
|
|
|
114
114
|
type DeepWritable<T extends {}> = Prettify<{
|
|
115
115
|
-readonly [K in keyof T]: T[K] extends Dictionary<any> ?
|
|
116
|
-
T[K] extends Date ? Date
|
|
116
|
+
T[K] extends Date ? Date
|
|
117
|
+
: T[K] extends Brand<infer R> ? Brand<R>
|
|
118
|
+
: DeepWritable<T[K]>
|
|
117
119
|
: T[K]
|
|
118
120
|
}>
|
|
119
121
|
|
package/src/@types/model.d.ts
CHANGED
|
@@ -35,10 +35,15 @@ declare namespace Model {
|
|
|
35
35
|
never
|
|
36
36
|
;
|
|
37
37
|
|
|
38
|
+
type HandleBrandTemplateEnvParamType<G extends unknown> =
|
|
39
|
+
G extends Brand<infer B> ? `${Brands[B]}` & { z__brand: B }
|
|
40
|
+
: `${G}`
|
|
41
|
+
;
|
|
42
|
+
|
|
38
43
|
type GetTemplateEnvParamType<const T extends PrimitiveValidationType<unknown, unknown>[]> =
|
|
39
|
-
T extends readonly [ PrimitiveValidationType<infer G, infer H> ] ?
|
|
40
|
-
T extends readonly [ PrimitiveValidationType<any, infer H>, PrimitiveValidationType<infer G, any> ] ?
|
|
41
|
-
T extends readonly [ PrimitiveValidationType<any, infer H>, ...any[], PrimitiveValidationType<infer G, any> ] ?
|
|
44
|
+
T extends readonly [ PrimitiveValidationType<infer G, infer H> ] ? HandleBrandTemplateEnvParamType<G> | H :
|
|
45
|
+
T extends readonly [ PrimitiveValidationType<any, infer H>, PrimitiveValidationType<infer G, any> ] ? HandleBrandTemplateEnvParamType<G> | H :
|
|
46
|
+
T extends readonly [ PrimitiveValidationType<any, infer H>, ...any[], PrimitiveValidationType<infer G, any> ] ? HandleBrandTemplateEnvParamType<G> | H :
|
|
42
47
|
never
|
|
43
48
|
;
|
|
44
49
|
|
|
@@ -34,6 +34,7 @@ describe('Brands', () => {
|
|
|
34
34
|
| AssertType<typeof modelTest.type['brandString'], string, true>
|
|
35
35
|
| AssertType<string, typeof modelTest.type['brandString'], false>
|
|
36
36
|
| AssertType<typeof modelTest.type['brandString'], Brand<'testeModel'>, true>
|
|
37
|
+
| AssertType<DeepWritable<{ readonly value: Brand<'testBrand'> }>, { value: Brand<'testBrand'> }, true>
|
|
37
38
|
;
|
|
38
39
|
|
|
39
40
|
it('preserva a referência e valor em runtime e altera apenas o tipo', () => {
|