Wrong input types derived from @effect/schema
It seems like trpc is unable to resolve the input types for a procedure I'm using.
The input is
And the resulting type is
This is from the webstorm hover.
Decode function type in thread (char limit)
I'm guessing for some reason, trpc get's confused specifically by the use of
.input(
Schema.decodeUnknownSync(
Schema.Struct({
authenticated: Schema.optionalWith(Schema.Boolean, {
default: () => false,
}),
limit: Schema.optionalWith(Schema.Number.pipe(Schema.nonNegative()), {
default: () => 100,
}),
offset: Schema.optionalWith(
Schema.Number.pipe(Schema.nonNegative()),
{
default: () => 0,
},
),
permissions: Schema.optionalWith(Schema.Array(PermissionSchema), {
default: () => [],
}),
roleIds: Schema.optionalWith(Schema.Array(Schema.NonEmptyString), {
default: () => [],
}),
}),
),
)
.input(
Schema.decodeUnknownSync(
Schema.Struct({
authenticated: Schema.optionalWith(Schema.Boolean, {
default: () => false,
}),
limit: Schema.optionalWith(Schema.Number.pipe(Schema.nonNegative()), {
default: () => 100,
}),
offset: Schema.optionalWith(
Schema.Number.pipe(Schema.nonNegative()),
{
default: () => 0,
},
),
permissions: Schema.optionalWith(Schema.Array(PermissionSchema), {
default: () => [],
}),
roleIds: Schema.optionalWith(Schema.Array(Schema.NonEmptyString), {
default: () => [],
}),
}),
),
)
input: { readonly permissions: readonly Permission[] readonly roleIds: readonly string[] readonly limit: number readonly offset: number readonly authenticated: boolean }
input: { readonly permissions: readonly Permission[] readonly roleIds: readonly string[] readonly limit: number readonly offset: number readonly authenticated: boolean }
optionalWith
as it works correctly with optional
Happy to provide context and figure this out.1 Reply
Here are the last promised types
Meanwhile the hover for my decoder function seems to be correct.
function decodeUnknownSync<{authenticated: boolean, limit: number, offset: number, permissions: readonly (Permission)[], roleIds: readonly string[]},{authenticated?: false | true | undefined, limit?: number | undefined, offset?: number | undefined, permissions?: readonly (Permission)[] | undefined, roleIds?: readonly string[] | undefined}>( schema: Schema.Schema<{authenticated: boolean, limit: number, offset: number, permissions: readonly (Permission)[], roleIds: readonly string[]}, {authenticated?: false | true | undefined, limit?: number | undefined, offset?: number | undefined, permissions?: readonly (Permission)[] | undefined, roleIds?: readonly string[] | undefined}, never>, options?: AST.ParseOptions, ): (u: unknown, overrideOptions?: AST.ParseOptions) => {authenticated: boolean, limit: number, offset: number, permissions: readonly (Permission)[], roleIds: readonly string[]}
function decodeUnknownSync<{authenticated: boolean, limit: number, offset: number, permissions: readonly (Permission)[], roleIds: readonly string[]},{authenticated?: false | true | undefined, limit?: number | undefined, offset?: number | undefined, permissions?: readonly (Permission)[] | undefined, roleIds?: readonly string[] | undefined}>( schema: Schema.Schema<{authenticated: boolean, limit: number, offset: number, permissions: readonly (Permission)[], roleIds: readonly string[]}, {authenticated?: false | true | undefined, limit?: number | undefined, offset?: number | undefined, permissions?: readonly (Permission)[] | undefined, roleIds?: readonly string[] | undefined}, never>, options?: AST.ParseOptions, ): (u: unknown, overrideOptions?: AST.ParseOptions) => {authenticated: boolean, limit: number, offset: number, permissions: readonly (Permission)[], roleIds: readonly string[]}