-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Which project does this relate to?
Router
Describe the bug
I'm having some typing issues with using connectrpc in tanstack start.
I have the following server function.
export const login = createServerFn()
.validator((data: unknown) => {
return data as LoginRequest
})
.handler(async ({ data }) => {
const authClient = await createGRPCClient(AuthService)
return await authClient.login({
email: data.email,
password: data.password,
})
})This results in this typing error.
TS2345: Argument of type
({data}: ServerFnCtx<Method, "data", undefined, (data: unknown) => LoginRequest>) => Promise<LoginResponse>
is not assignable to parameter of type
ServerFn<Method, "data", undefined, (data: unknown) => LoginRequest, LoginResponse>
Type 'Promise<LoginResponse>' is not assignable to type 'Promise<{ readonly $typeName: "api.auth.v1.LoginResponse"; $unknown?: { readonly no: number; readonly wireType: WireType; readonly data: { [x: number]: number; readonly BYTES_PER_ELEMENT: number; ... 32 more ...; readonly [Symbol.toStringTag]: "Uint8Array"; }; }[] | undefined; jwt: string; }> | { ...; }'.
Type 'Promise<LoginResponse>' is not assignable to type 'Promise<{ readonly $typeName: "api.auth.v1.LoginResponse"; $unknown?: { readonly no: number; readonly wireType: WireType; readonly data: { [x: number]: number; readonly BYTES_PER_ELEMENT: number; ... 32 more ...; readonly [Symbol.toStringTag]: "Uint8Array"; }; }[] | undefined; jwt: string; }>'.
Type 'LoginResponse' is not assignable to type '{ readonly $typeName: "api.auth.v1.LoginResponse"; $unknown?: { readonly no: number; readonly wireType: WireType; readonly data: { [x: number]: number; readonly BYTES_PER_ELEMENT: number; ... 32 more ...; readonly [Symbol.toStringTag]: "Uint8Array"; }; }[] | undefined; jwt: string; }'.
Types of property $unknown are incompatible.
Type 'UnknownField[] | undefined' is not assignable to type '{ readonly no: number; readonly wireType: WireType; readonly data: { [x: number]: number; readonly BYTES_PER_ELEMENT: number; readonly buffer: { readonly byteLength: number; slice: "Function is not serializable"; readonly [Symbol.toStringTag]: "ArrayBuffer"; } | { ...; }; ... 31 more ...; readonly [Symbol.toStringTa...'.
Type 'UnknownField[]' is not assignable to type '{ readonly no: number; readonly wireType: WireType; readonly data: { [x: number]: number; readonly BYTES_PER_ELEMENT: number; readonly buffer: { readonly byteLength: number; slice: "Function is not serializable"; readonly [Symbol.toStringTag]: "ArrayBuffer"; } | { ...; }; ... 31 more ...; readonly [Symbol.toStringTa...'.
Type 'UnknownField' is not assignable to type '{ readonly no: number; readonly wireType: WireType; readonly data: { [x: number]: number; readonly BYTES_PER_ELEMENT: number; readonly buffer: { readonly byteLength: number; slice: "Function is not serializable"; readonly [Symbol.toStringTag]: "ArrayBuffer"; } | { ...; }; ... 31 more ...; readonly [Symbol.toStringTa...'.
The types of data.buffer are incompatible between these types.
Type ArrayBufferLike is not assignable to type
{
readonly byteLength: number;
slice: "Function is not serializable";
readonly [Symbol.toStringTag]: "ArrayBuffer";
} | {
readonly byteLength: number;
slice: "Function is not serializable";
readonly [Symbol.toStringTag]: "SharedArrayBuffer";
}
Type ArrayBuffer is not assignable to type
{
readonly byteLength: number;
slice: "Function is not serializable";
readonly [Symbol.toStringTag]: "ArrayBuffer";
} | {
readonly byteLength: number;
slice: "Function is not serializable";
readonly [Symbol.toStringTag]: "SharedArrayBuffer";
}
Type ArrayBuffer is not assignable to type
{
readonly byteLength: number;
slice: "Function is not serializable";
readonly [Symbol.toStringTag]: "ArrayBuffer";
}
Types of property slice are incompatible.
Type
(begin?: number | undefined, end?: number | undefined) => ArrayBuffer
is not assignable to type "Function is not serializable"I have also tried using the create function but this produces the same error.
Also see the issue here: bufbuild/protobuf-es#1232
Using json_types is not a proper solution as important type information gets lost
Your Example Website or App
https://github.com/Quadrubo/protoc-arraybuffer-repro
Steps to Reproduce the Bug or Issue
Follow the steops in this repro repo: https://github.com/Quadrubo/protoc-arraybuffer-repro
Expected behavior
I expect to receive no type errors and be able to use server functions like normal.
Screenshots or Videos
No response
Platform
- Router / Start Version: 1.141.7
- Bundler: vite
- Bundler Version: 7.3.0
Additional context
No response
afsals-xbitcoderabbitai
Metadata
Metadata
Assignees
Labels
No labels