You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
importtype{RequestHandler}from"@sveltejs/kit";interfaceGetOutput{item: {message: string}}// No TS errorexportconstget: RequestHandler<any,GetOutput>=async()=>{return{status: 200,body: {item: {message: 'hello'},},};};interfaceItem{message: string;}interfacePostOutput{item: Item;}// TS error: Type '{ message: string; }' is not assignable to type 'never'.ts(2322)exportconstpost: RequestHandler<any,PostOutput>=async()=>{return{status: 200,body: {item: {message: 'hello'},},};};
Logs
Output of svelte-check:
sveltekit-endpoint-output-nested-interfaces-repro/src/routes/index.ts:26:14
Error: Type '() => Promise<{ status: number; body: { item: { message: string; }; }; }>' is not assignable to type'RequestHandler<any, PostOutput>'.
Type 'Promise<{ status: number; body: { item: { message: string; }; }; }>' is not assignable to type'MaybePromise<RequestHandlerOutput<PostOutput>>'.
Type 'Promise<{ status: number; body: { item: { message: string; }; }; }>' is not assignable to type'Promise<RequestHandlerOutput<PostOutput>>'.
Type '{ status: number; body: { item: { message: string; }; }; }' is not assignable to type'RequestHandlerOutput<PostOutput>'.
The types of 'body.item' are incompatible between these types.
Type '{ message: string; }' is not assignable to type'never'.
export const post: RequestHandler<any, PostOutput> = async () => {
Thank you for the thorough report. Seems like the initial problem of interfaces not having implicit index signatures is still apparent when nested as properties. Changing Item from an interface to a type alias removes the error, so I guess something is not working with the recursive check.
Describe the bug
This is a follow-up on #1997, which was recently fixed in #4897.
The new
BodyValidator
type seems to work well, but it doesn't seem to work with interfaces that have properties which are themselves interfaces.Reproduction
If you prefer a repository: check out this file in flut1/sveltekit-endpoint-output-nested-interfaces-repro
Logs
Output of svelte-check:
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: