Closed
Description
Which project does this relate to?
Start
Describe the bug
The following:
const testUnknown = createServerFn().handler(() => {
return {} as unknown as { a: unknown };
});
produces this error:
Argument of type '() => { a: unknown; }' is not assignable to parameter of type 'ServerFn<Method, "data", undefined, undefined, { a: unknown; }>'.
Type '{ a: unknown; }' is not assignable to type 'Promise<{ a: {}; }> | { a: {}; }'.
Type '{ a: unknown; }' is not assignable to type '{ a: {}; }'.
Types of property 'a' are incompatible.
Type 'unknown' is not assignable to type '{}'.ts(2345)
Your Example Website or App
https://stackblitz.com/edit/github-jwt7xpxn?file=src%2Froutes%2Findex.tsx
Steps to Reproduce the Bug or Issue
- Go to https://stackblitz.com/edit/github-jwt7xpxn?file=src%2Froutes%2Findex.tsx
- Go to index.tsx
- See TS error in server fn
Expected behavior
The return type of the server fn should include the never
type and not {}
.
Screenshots or Videos
No response
Platform
- OS: macOS
- TS: 5.8.3
- Tanstack Router: 1.121.2
- Tanstack Start: 1.121.7
Additional context
My api endpoint is returning data that might include the unknown type and I want to be able to handle that in my components.
Metadata
Metadata
Assignees
Labels
No labels