Skip to content

Commit d3b201f

Browse files
authored
chore: upgrade TSTyche (#4877)
1 parent 1424a34 commit d3b201f

File tree

6 files changed

+36
-55
lines changed

6 files changed

+36
-55
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
"playwright": "^1.52.0",
7070
"prettier": "^3.5.3",
7171
"rimraf": "^6.0.1",
72-
"tstyche": "^4.0.0-beta.9",
72+
"tstyche": "^4.0.0-rc.0",
7373
"tsx": "^4.19.4",
7474
"typescript": "^5.8.3",
7575
"vite": "^6.1.1",

packages/effect/dtslint/Function.tst.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { flow, Function, identity, Option, pipe } from "effect"
2-
import { describe, it } from "tstyche"
2+
import { describe, expect, it } from "tstyche"
33

44
describe("Function", () => {
55
describe("pipe", () => {
@@ -37,17 +37,14 @@ describe("Function", () => {
3737
const arg2 = (a: string, b: number) => `${a}${b}`
3838
const arg3 = (a: number) => a
3939

40-
const _a1: number = apply1(countArgs)
41-
const _a2: string = apply1(arg1)
42-
// @ts-expect-error: Target signature provides too few arguments. Expected 2 or more, but got 1.
43-
apply1(arg2)
44-
// @ts-expect-error: Type 'string' is not assignable to type 'number'.
45-
apply1(arg3)
40+
expect(apply1(countArgs)).type.toBe<number>()
41+
expect(apply1(arg1)).type.toBe<string>()
42+
expect(apply1).type.not.toBeCallableWith(arg2)
43+
expect(apply1).type.not.toBeCallableWith(arg3)
4644

47-
const _b1: number = apply2(countArgs)
48-
const _b2: string = apply2(arg1)
49-
const _b3: string = apply2(arg2)
50-
// @ts-expect-error: Type 'string' is not assignable to type 'number'.
51-
apply1(arg3)
45+
expect(apply2(countArgs)).type.toBe<number>()
46+
expect(apply2(arg1)).type.toBe<string>()
47+
expect(apply2(arg2)).type.toBe<string>()
48+
expect(apply1).type.not.toBeCallableWith(arg3)
5249
})
5350
})

packages/effect/dtslint/Option.tst.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ describe("Option", () => {
187187
expect(Option.firstSomeOf<number>).type.not.toBeCallableWith(
188188
[number, string]
189189
)
190-
pipe(
191-
// @ts-expect-error: Type 'string' is not assignable to type 'number'
190+
expect(pipe).type.not.toBeCallableWith(
192191
[number, string],
193192
Option.firstSomeOf<number>
194193
)
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable @typescript-eslint/no-unused-vars */
22
import { pipe, Schema } from "effect"
3-
import { describe, it } from "tstyche"
3+
import { describe, expect, it } from "tstyche"
44

55
const Int1 = Symbol.for("Int")
66
const Int2 = Symbol.for("Int")
@@ -11,12 +11,9 @@ const schema2 = pipe(Schema.Number, Schema.int(), Schema.brand(Int2))
1111
type A1 = Schema.Schema.Type<typeof schema1>
1212
type A2 = Schema.Schema.Type<typeof schema2>
1313

14-
declare const a2: A2
15-
declare const f: (int: A1) => void
16-
1714
describe("SchemaBrand", () => {
18-
it("We should only have one error for the missing definition", () => {
19-
// @ts-expect-error
20-
f(a2)
15+
it("should differentiate between branded schema types", () => {
16+
expect<A1>().type.not.toBeAssignableTo<A2>()
17+
expect<A2>().type.not.toBeAssignableTo<A1>()
2118
})
2219
})

packages/effect/dtslint/Schema/Schema.tst.ts

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2412,17 +2412,15 @@ describe("Schema", () => {
24122412
})
24132413

24142414
it("withDecodingDefault", () => {
2415-
S.Struct({
2416-
a: S.optional(S.String).pipe(
2415+
when(S.Struct).isCalledWith({
2416+
a: when(S.optional(S.String).pipe).isCalledWith(
24172417
S.withConstructorDefault(() => undefined),
2418-
// @ts-expect-error
2419-
S.withDecodingDefault(() => "")
2418+
expect(S.withDecodingDefault).type.not.toBeCallableWith(() => "")
24202419
)
24212420
})
2422-
S.Struct({
2423-
a: S.optional(S.String).pipe(
2424-
// @ts-expect-error
2425-
S.withDecodingDefault(() => undefined)
2421+
when(S.Struct).isCalledWith({
2422+
a: when(S.optional(S.String).pipe).isCalledWith(
2423+
expect(S.withDecodingDefault).type.not.toBeCallableWith(() => undefined)
24262424
)
24272425
})
24282426
expect(
@@ -2435,12 +2433,10 @@ describe("Schema", () => {
24352433
})
24362434

24372435
it("withDefaults", () => {
2438-
S.Struct({
2439-
a: S.optional(S.String).pipe(
2440-
S.withDefaults({
2441-
// @ts-expect-error
2436+
when(S.Struct).isCalledWith({
2437+
a: when(S.optional(S.String).pipe).isCalledWith(
2438+
expect(S.withDefaults).type.not.toBeCallableWith({
24422439
decoding: () => undefined,
2443-
// @ts-expect-error
24442440
constructor: () => undefined
24452441
})
24462442
)
@@ -2753,9 +2749,8 @@ describe("Schema", () => {
27532749
// should allow generic context
27542750
const _f1 = <A extends string>(schema: S.Schema<A>) => schema.pipe(S.maxLength(5))
27552751
const _f2 = <A extends string>(schema: S.Schema<A>) =>
2756-
schema.pipe(
2757-
// @ts-expect-error: Type 'string' is not assignable to type 'number'
2758-
S.greaterThan(5)
2752+
when(schema.pipe).isCalledWith(
2753+
expect(S.greaterThan).type.not.toBeCallableWith(5)
27592754
)
27602755
// should allow string subtypes
27612756
pipe(
@@ -3540,12 +3535,8 @@ describe("Schema", () => {
35403535
>(schema: S.Schema<A, I>) => S.DataFromSelf(schema)
35413536
const _f3 = <A extends Readonly<Record<string, unknown>> | ReadonlyArray<unknown>, I extends number>(
35423537
schema: S.Schema<A, I>
3543-
) =>
3544-
// @ts-expect-error: Type 'number' is not assignable to type 'Readonly<Record<string, unknown>>'
3545-
S.DataFromSelf(schema)
3546-
const _f4 = <A extends string>(schema: S.Schema<A>) =>
3547-
// @ts-expect-error: Type 'string' is not assignable to type 'Readonly<Record<string, unknown>>'
3548-
S.DataFromSelf(schema)
3538+
) => expect(S.DataFromSelf).type.not.toBeCallableWith(schema)
3539+
const _f4 = <A extends string>(schema: S.Schema<A>) => expect(S.DataFromSelf).type.not.toBeCallableWith(schema)
35493540

35503541
// should allow mutable arguments
35513542
S.DataFromSelf(S.mutable(S.Struct({ a: S.NumberFromString })))
@@ -4105,8 +4096,7 @@ describe("Schema", () => {
41054096
})
41064097

41074098
it("head", () => {
4108-
// @ts-expect-error: Type 'string' is not assignable to type 'readonly unknown[]'
4109-
S.String.pipe(S.head)
4099+
expect(S.String.pipe).type.not.toBeCallableWith(S.head)
41104100

41114101
const schema = S.head(S.Array(S.NumberFromString))
41124102

@@ -4120,8 +4110,7 @@ describe("Schema", () => {
41204110
})
41214111

41224112
it("headNonEmpty", () => {
4123-
// @ts-expect-error: Type 'string' is not assignable to type 'readonly [unknown, ...unknown[]]'
4124-
S.String.pipe(S.headNonEmpty)
4113+
expect(S.String.pipe).type.not.toBeCallableWith(S.headNonEmpty)
41254114

41264115
const schema = S.headNonEmpty(S.NonEmptyArray(S.Number))
41274116
expect(S.asSchema(schema)).type.toBe<S.Schema<number, readonly [number, ...Array<number>]>>()
@@ -4134,8 +4123,7 @@ describe("Schema", () => {
41344123
})
41354124

41364125
it("headOrElse", () => {
4137-
// @ts-expect-error: Type 'string' is not assignable to type 'readonly unknown[]'
4138-
S.String.pipe(S.headOrElse())
4126+
expect(S.String.pipe).type.not.toBeCallableWith(S.headOrElse())
41394127
expect(S.headOrElse).type.not.toBeCallableWith(S.Array(S.Number), () => "a")
41404128
when(S.Array(S.Number).pipe).isCalledWith(expect(S.headOrElse).type.not.toBeCallableWith(() => "a"))
41414129

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)