Commit d0695a7
authored
fix(typescript):
Using `RouteDataFunc` without specifying any generic types results in `RouteDataFunc<unknown, unknown>`, which `RouteDataFunc<NotUnknown, unknown>` does not extend. See https://stackblitz.com/edit/solid-ssr-vite-pcbdkr?file=tsconfig.json,src%2Froutes%2Findex.tsx:
```
Expected 1 arguments, but got 0.(2554)
index.tsx(7, 25): An argument for 'args' was not provided.
```
Since `(args: RouteDataArgs<typeof routeData>) => (() => undefined) | (() => string)` does not extend `RouteDataFunc<unknown, unknown>`, the type is not `ReturnType<T>` but `T`.
This change makes it so that that case is properly handled and typed. I avoided using `any` but the change would otherwise be equivalent to:
```ts
data: T extends RouteDataFunc<any> ? ReturnType<T> : T;
```RouteDataFuncArgs.data incorrect type (#263)1 parent b2b1313 commit d0695a7
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
0 commit comments