Skip to content

Commit ff9df55

Browse files
committed
chore: update TS+ and remove not needed lazy
1 parent eeae117 commit ff9df55

File tree

131 files changed

+901
-336
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+901
-336
lines changed

.changeset/loud-otters-share.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@tsplus/runtime": patch
3+
"@tsplus/stdlib": patch
4+
---
5+
6+
Removed Not Needed Lazy and Update TS+

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
"@effect-ts/build-utils": "0.40.3",
4040
"@effect-ts/core": "^0.60.2",
4141
"@repo-tooling/eslint-plugin-dprint": "^0.0.4",
42-
"@tsplus/installer": "0.0.132",
43-
"@types/node": "^18.6.4",
42+
"@tsplus/installer": "0.0.133",
43+
"@types/node": "^18.6.5",
4444
"@types/rimraf": "^3.0.2",
45-
"@typescript-eslint/eslint-plugin": "^5.32.0",
46-
"@typescript-eslint/parser": "^5.32.0",
45+
"@typescript-eslint/eslint-plugin": "^5.33.0",
46+
"@typescript-eslint/parser": "^5.33.0",
4747
"babel-plugin-annotate-pure-calls": "^0.4.0",
4848
"babel-plugin-replace-import-extension": "^1.1.3",
4949
"c8": "^7.12.0",
@@ -60,8 +60,8 @@
6060
"rimraf": "^3.0.2",
6161
"typescript": "^4.7.4",
6262
"ultra-runner": "^3.10.5",
63-
"vite": "^3.0.4",
64-
"vitest": "0.20.3"
63+
"vite": "^3.0.5",
64+
"vitest": "0.21.1"
6565
},
6666
"resolutions": {
6767
"eslint-plugin-codegen": "patch:eslint-plugin-codegen@npm:0.16.1#.yarn/patches/eslint-plugin-codegen-npm-0.16.1-87770191cd"

packages/runtime/_src/Brand.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ export declare namespace Brand {
3434

3535
export type Brands<P> = P extends Valid<any, any> ? TypeLevel.UnionToIntersection<
3636
{
37-
[k in keyof P[Brand.valid]]: P extends P[Brand.valid][k] ? k extends string ? Valid<P[Brand.valid][k], k> : never
37+
[k in keyof P[Brand.valid]]: P extends P[Brand.valid][k]
38+
? k extends string ? Valid<P[Brand.valid][k], k> : never
3839
: never
3940
}[keyof P[Brand.valid]]
4041
>
@@ -79,18 +80,23 @@ export declare namespace Brand {
7980
readonly validate: (a: A) => a is A & Brand.Valid<A, K>
8081
}
8182

82-
export type ValidatedWith<X extends Validation<any, any>> = X extends Validation<infer A, infer K> ? Validated<A, K>
83+
export type ValidatedWith<X extends Validation<any, any>> = X extends Validation<infer A, infer K>
84+
? Validated<A, K>
8385
: never
8486

8587
/**
8688
* @tsplus type Brand/Ops
8789
*/
8890
export interface Ops {
89-
readonly validation: <A, K extends string>(predicate: (a: A) => boolean) => Brand.Validation<A, K>
91+
readonly validation: <A, K extends string>(
92+
predicate: (a: A) => boolean
93+
) => Brand.Validation<A, K>
9094
}
9195
}
9296

93-
export function validation<A, K extends string>(predicate: (a: A) => boolean): Brand.Validation<A, K> {
97+
export function validation<A, K extends string>(
98+
predicate: (a: A) => boolean
99+
): Brand.Validation<A, K> {
94100
return {
95101
validate: (value): value is Brand.Validated<A, K> => predicate(value)
96102
}

packages/runtime/_src/Decoder.ts

Lines changed: 74 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ export const Decoder: DecoderOps = {}
2424
/**
2525
* @tsplus static Decoder/Ops __call
2626
*/
27-
export function make<A>(decodeResult: (u: unknown) => Result<Decoder.Error, Decoder.Error, A>): Decoder<A> {
27+
export function make<A>(
28+
decodeResult: (u: unknown) => Result<Decoder.Error, Decoder.Error, A>
29+
): Decoder<A> {
2830
return {
2931
decodeResult
3032
}
@@ -82,7 +84,10 @@ export class DecoderErrorPrimitive implements Decoder.Error {
8284
readonly expectedType: string
8385
) {}
8486
render = () => {
85-
return Tree(`Expected a value of type "${this.expectedType}" but received one of type "${typeof this.value}"`)
87+
return Tree(
88+
`Expected a value of type "${this.expectedType}" but received one of type "${typeof this
89+
.value}"`
90+
)
8691
}
8792
}
8893

@@ -100,7 +105,10 @@ export class DecoderErrorIsoDateMalformed implements Decoder.Error {
100105
readonly value: unknown
101106
) {}
102107
render = () => {
103-
return Tree(`Expected a Date represented as an iso string instead received one of type "${typeof this.value}"`)
108+
return Tree(
109+
`Expected a Date represented as an iso string instead received one of type "${typeof this
110+
.value}"`
111+
)
104112
}
105113
}
106114

@@ -116,7 +124,9 @@ export class DecoderErrorLiteral implements Decoder.Error {
116124
` of type "${typeof this.expected}"` :
117125
""
118126
} instead received ${
119-
typeof this.value === typeof this.expected ? `"${this.value}"` : `one of type "${typeof this.value}"`
127+
typeof this.value === typeof this.expected ?
128+
`"${this.value}"` :
129+
`one of type "${typeof this.value}"`
120130
}`
121131
)
122132
}
@@ -138,18 +148,24 @@ export class DecoderErrorStruct implements Decoder.Error {
138148
constructor(
139149
readonly fields: Chunk<DecoderErrorStructFieldError>
140150
) {}
141-
render = () => Tree(`Encountered while parsing an object structure`, this.fields.map((d) => d.render()))
151+
render = () =>
152+
Tree(`Encountered while parsing an object structure`, this.fields.map((d) => d.render()))
142153
}
143154

144155
export class DecoderErrorTaggedMalformed implements Decoder.Error {
145156
constructor(readonly keys: string[]) {}
146157
render = () =>
147-
Tree(`Expected a tagged object of the form "{ _tag: ${this.keys.sort().map(k => `"${k}"`).join(" | ")} }"`)
158+
Tree(
159+
`Expected a tagged object of the form "{ _tag: ${
160+
this.keys.sort().map(k => `"${k}"`).join(" | ")
161+
} }"`
162+
)
148163
}
149164

150165
export class DecoderErrorTaggedInner implements Decoder.Error {
151166
constructor(readonly tag: string, readonly error: Decoder.Error) {}
152-
render = () => Tree(`Encountered while processing tagged object "${this.tag}"`, Chunk(this.error.render()))
167+
render = () =>
168+
Tree(`Encountered while processing tagged object "${this.tag}"`, Chunk(this.error.render()))
153169
}
154170

155171
export class DecoderErrorUnionMember implements Decoder.Error {
@@ -171,7 +187,9 @@ export class DecoderErrorArray implements Decoder.Error {
171187
render = () =>
172188
Tree(
173189
`Encountered while processing an Array of elements`,
174-
this.errors.map(([n, err]) => Tree(`Encountered while processing element "${n}"`, Chunk(err.render())))
190+
this.errors.map(([n, err]) =>
191+
Tree(`Encountered while processing element "${n}"`, Chunk(err.render()))
192+
)
175193
)
176194
}
177195

@@ -191,35 +209,45 @@ export class DecoderErrorValidation implements Decoder.Error {
191209
* @tsplus implicit
192210
*/
193211
export const _true: Decoder<true> = Decoder((u) =>
194-
Derive<Guard<true>>().is(u) ? Result.success(u) : Result.fail(new DecoderErrorPrimitive(u, "true"))
212+
Derive<Guard<true>>().is(u) ?
213+
Result.success(u) :
214+
Result.fail(new DecoderErrorPrimitive(u, "true"))
195215
)
196216

197217
/**
198218
* @tsplus implicit
199219
*/
200220
export const _false: Decoder<false> = Decoder((u) =>
201-
Derive<Guard<false>>().is(u) ? Result.success(u) : Result.fail(new DecoderErrorPrimitive(u, "false"))
221+
Derive<Guard<false>>().is(u) ?
222+
Result.success(u) :
223+
Result.fail(new DecoderErrorPrimitive(u, "false"))
202224
)
203225

204226
/**
205227
* @tsplus implicit
206228
*/
207229
export const boolean: Decoder<boolean> = Decoder((u) =>
208-
Derive<Guard<boolean>>().is(u) ? Result.success(u) : Result.fail(new DecoderErrorPrimitive(u, "boolean"))
230+
Derive<Guard<boolean>>().is(u) ?
231+
Result.success(u) :
232+
Result.fail(new DecoderErrorPrimitive(u, "boolean"))
209233
)
210234

211235
/**
212236
* @tsplus implicit
213237
*/
214238
export const string: Decoder<string> = Decoder((u) =>
215-
Derive<Guard<string>>().is(u) ? Result.success(u) : Result.fail(new DecoderErrorPrimitive(u, "string"))
239+
Derive<Guard<string>>().is(u) ?
240+
Result.success(u) :
241+
Result.fail(new DecoderErrorPrimitive(u, "string"))
216242
)
217243

218244
/**
219245
* @tsplus implicit
220246
*/
221247
export const number: Decoder<number> = Decoder((u) =>
222-
Derive<Guard<number>>().is(u) ? Result.success(u) : Result.fail(new DecoderErrorPrimitive(u, "number"))
248+
Derive<Guard<number>>().is(u) ?
249+
Result.success(u) :
250+
Result.fail(new DecoderErrorPrimitive(u, "number"))
223251
)
224252

225253
/**
@@ -374,27 +402,37 @@ export function deriveArray<A extends Array<any>>(
374402
if (hasFailed) {
375403
return Result.fail(new DecoderErrorArray(errors))
376404
}
377-
return Result.success(out as A, errors.isEmpty ? Maybe.none : Maybe.some(new DecoderErrorArray(errors)))
405+
return Result.success(
406+
out as A,
407+
errors.isEmpty ? Maybe.none : Maybe.some(new DecoderErrorArray(errors))
408+
)
378409
}
379410
return Result.fail(new DecoderErrorPrimitive(u, "Array"))
380411
})
381412
}
382413

383414
type EitherStructural<E, A> = { _tag: "Left"; left: E } | { _tag: "Right"; right: A }
384415

385-
function deriveEitherInternal<E, A>(left: Decoder<E>, right: Decoder<A>): Decoder<EitherStructural<E, A>> {
416+
function deriveEitherInternal<E, A>(
417+
left: Decoder<E>,
418+
right: Decoder<A>
419+
): Decoder<EitherStructural<E, A>> {
386420
return Derive()
387421
}
388422

389423
/**
390424
* @tsplus derive Decoder[Either]<_> 10
391425
*/
392426
export function deriveEither<A extends Either<any, any>>(
393-
...[left, right]: [A] extends [Either<infer _E, infer _A>] ? [left: Decoder<_E>, right: Decoder<_A>] : never
427+
...[left, right]: [A] extends [Either<infer _E, infer _A>]
428+
? [left: Decoder<_E>, right: Decoder<_A>]
429+
: never
394430
): Decoder<A> {
395431
const structural = deriveEitherInternal(left, right)
396432
return Decoder((u) =>
397-
structural.decodeResult(u).map((e) => e._tag === "Left" ? Either.left(e.left) as A : Either.right(e.right) as A)
433+
structural.decodeResult(u).map((e) =>
434+
e._tag === "Left" ? Either.left(e.left) as A : Either.right(e.right) as A
435+
)
398436
)
399437
}
400438

@@ -415,7 +453,9 @@ export function deriveMaybe<A extends Maybe<any>>(
415453
): Decoder<A> {
416454
const structural = deriveMaybeInternal(value)
417455
return Decoder((u) =>
418-
structural.decodeResult(u).map((e) => e._tag === "Some" ? Maybe.some(e.value) as A : Maybe.none as A)
456+
structural.decodeResult(u).map((e) =>
457+
e._tag === "Some" ? Maybe.some(e.value) as A : Maybe.none as A
458+
)
419459
)
420460
}
421461

@@ -424,14 +464,16 @@ export class DecoderErrorRecordValue implements Decoder.Error {
424464
readonly key: string,
425465
readonly error: Decoder.Error
426466
) {}
427-
render = () => Tree(`Encountered while parsing a record value at "${this.key}"`, Chunk(this.error.render()))
467+
render = () =>
468+
Tree(`Encountered while parsing a record value at "${this.key}"`, Chunk(this.error.render()))
428469
}
429470

430471
export class DecoderErrorRecordFields implements Decoder.Error {
431472
constructor(
432473
readonly fields: Chunk<Decoder.Error>
433474
) {}
434-
render = () => Tree(`Encountered while parsing a record structure`, this.fields.map((d) => d.render()))
475+
render = () =>
476+
Tree(`Encountered while parsing a record structure`, this.fields.map((d) => d.render()))
435477
}
436478

437479
export class DecoderErrorRecordMissingKeys implements Decoder.Error {
@@ -440,7 +482,9 @@ export class DecoderErrorRecordMissingKeys implements Decoder.Error {
440482
) {}
441483
render = () =>
442484
Tree(
443-
`Encountered while parsing a record structure, missing keys: ${this.missing.map((k) => `"${k}"`).join(", ")}`
485+
`Encountered while parsing a record structure, missing keys: ${
486+
this.missing.map((k) => `"${k}"`).join(", ")
487+
}`
444488
)
445489
}
446490

@@ -452,7 +496,9 @@ export function deriveEmptyRecord<A extends {}>(
452496
): Decoder<A> {
453497
const record = Derive<Guard<{}>>()
454498
// @ts-expect-error
455-
return Decoder((u) => record.is(u) ? Result.success(u) : Result.fail(new DecoderErrorPrimitive(u, "{}")))
499+
return Decoder((u) =>
500+
record.is(u) ? Result.success(u) : Result.fail(new DecoderErrorPrimitive(u, "{}"))
501+
)
456502
}
457503

458504
/**
@@ -553,9 +599,13 @@ export function deriveRecord<A extends Record<string, any>>(
553599
* @tsplus derive Decoder<_> 20
554600
*/
555601
export function deriveLiteral<A extends string | number>(
556-
...[value]: Check<Check.IsLiteral<A> & Check.Not<Check.IsUnion<A>>> extends Check.True ? [value: A] : never
602+
...[value]: Check<Check.IsLiteral<A> & Check.Not<Check.IsUnion<A>>> extends Check.True
603+
? [value: A]
604+
: never
557605
): Decoder<A> {
558-
return Decoder((u) => u === value ? Result.success(u as A) : Result.fail(new DecoderErrorLiteral(value, u)))
606+
return Decoder((u) =>
607+
u === value ? Result.success(u as A) : Result.fail(new DecoderErrorLiteral(value, u))
608+
)
559609
}
560610

561611
/**

packages/runtime/_src/Encoder.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ export function deriveNamed<A extends Brand<any>>(
9191
* @tsplus derive Encoder<_> 10
9292
*/
9393
export function deriveValidation<A extends Brand.Valid<any, any>>(
94-
...[base]: Check<Brand.IsValidated<A>> extends Check.True ? [base: Encoder<Brand.Unbranded<A>>] : never
94+
...[base]: Check<Brand.IsValidated<A>> extends Check.True ? [base: Encoder<Brand.Unbranded<A>>]
95+
: never
9596
): Encoder<A> {
9697
return Encoder((a) => base.encode(a as Brand.Unbranded<A>))
9798
}
@@ -112,15 +113,20 @@ export function deriveLazy<A>(fn: (_: Encoder<A>) => Encoder<A>): Encoder<A> {
112113

113114
type EitherStructural<E, A> = { _tag: "Left"; left: E } | { _tag: "Right"; right: A }
114115

115-
function deriveEitherInternal<E, A>(left: Encoder<E>, right: Encoder<A>): Encoder<EitherStructural<E, A>> {
116+
function deriveEitherInternal<E, A>(
117+
left: Encoder<E>,
118+
right: Encoder<A>
119+
): Encoder<EitherStructural<E, A>> {
116120
return Derive()
117121
}
118122

119123
/**
120124
* @tsplus derive Encoder[Either]<_> 10
121125
*/
122126
export function deriveEither<A extends Either<any, any>>(
123-
...[left, right]: [A] extends [Either<infer _E, infer _A>] ? [left: Encoder<_E>, right: Encoder<_A>] : never
127+
...[left, right]: [A] extends [Either<infer _E, infer _A>]
128+
? [left: Encoder<_E>, right: Encoder<_A>]
129+
: never
124130
): Encoder<A> {
125131
const structural = deriveEitherInternal(left, right)
126132
return Encoder((u) => structural.encode(u))
@@ -250,7 +256,9 @@ export function deriveRecord<A extends Record<string, any>>(
250256
* @tsplus derive Encoder<_> 20
251257
*/
252258
export function deriveLiteral<A extends string | number>(
253-
...[value]: Check<Check.IsLiteral<A> & Check.Not<Check.IsUnion<A>>> extends Check.True ? [value: A] : never
259+
...[value]: Check<Check.IsLiteral<A> & Check.Not<Check.IsUnion<A>>> extends Check.True
260+
? [value: A]
261+
: never
254262
): Encoder<A> {
255263
return Encoder(() => value)
256264
}

0 commit comments

Comments
 (0)