RouteDataArgs Type Error for nested RouteData

// Root
export function routeData(args: RouteDataArgs) {
return () => 'foo'
}

// Child
export function routeData(args: RouteDataArgs<typeof RootRouteData>) {
return args.data() ? args.data() : () => 'bar'
}

// Grandchild
export function routeData(args: RouteDataArgs<typeof ChildRouteData>) {
return args.data() // <= TypeError. An Argument for "args" was not provided.
}
// Root
export function routeData(args: RouteDataArgs) {
return () => 'foo'
}

// Child
export function routeData(args: RouteDataArgs<typeof RootRouteData>) {
return args.data() ? args.data() : () => 'bar'
}

// Grandchild
export function routeData(args: RouteDataArgs<typeof ChildRouteData>) {
return args.data() // <= TypeError. An Argument for "args" was not provided.
}
Wha'ts happening here? I tried to reproduce this in Stackblitz and couldn't. I'm guessing some TS config option maybe as type inference seems a bit messed up. https://stackblitz.com/edit/solid-ssr-vite-pcbdkr?file=src%2Froutes%2Findex.tsx However, locally, routeData return types are accurate and I get above error for this kind of structure.
1 Reply
Martnart
MartnartOP2y ago
Update: I just had to enable "strict" in TSConfig, now the issue is reproducible. Is this expected? Can't be, right? Runtime there are no issues, only TS complains
Want results from more Discord servers?
Add your server