Commit cf93aab
fix: allow optional types for remote query/command/prerender functions (sveltejs#15293)
We're using the `arg: undefined extends Input ? Input | void : Input`
method and not the `...args: undefined extends Input ? [arg?: Input] :
[arg: Input]` method because the former does work in more cases (the
latter throws a type error in our own code around generics), even though
the TS team likely wants us to use the latter (but that pattern is in so
many code bases now that this behavior around `void` will never change).
One drawback (of either method) is that without strict mode all
commands/queries/prerenders have optional args now, because `undefined
extends X` is always `true` in non-strict mode. But since noone who uses
type checking nowadays should use non-strict mode anyway, it's fine.
fixes sveltejs#14500
---
### Please don't delete this checklist! Before submitting the PR, please
make sure you do the following:
- [x] It's really useful if your PR references an issue where it is
discussed ahead of time. In many cases, features are absent for a
reason. For large changes, please create an RFC:
https://github.com/sveltejs/rfcs
- [x] This message body should clearly illustrate what problems it
solves.
- [x] Ideally, include a test that fails without this PR but passes with
it.
### Tests
- [x] Run the tests with `pnpm test` and lint the project with `pnpm
lint` and `pnpm check`
### Changesets
- [x] If your PR makes a change that should be noted in one or more
packages' changelogs, generate a changeset by running `pnpm changeset`
and following the prompts. Changesets that add features should be
`minor` and those that fix bugs should be `patch`. Please prefix
changeset messages with `feat:`, `fix:`, or `chore:`.
Co-authored-by: Tee Ming <chewteeming01@gmail.com>1 parent a732d30 commit cf93aab
File tree
4 files changed
+65
-6
lines changed- .changeset
- packages/kit
- src/exports
- test/types
- types
4 files changed
+65
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2110 | 2110 | | |
2111 | 2111 | | |
2112 | 2112 | | |
2113 | | - | |
| 2113 | + | |
2114 | 2114 | | |
2115 | 2115 | | |
2116 | 2116 | | |
| |||
2180 | 2180 | | |
2181 | 2181 | | |
2182 | 2182 | | |
2183 | | - | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
2184 | 2186 | | |
2185 | 2187 | | |
2186 | 2188 | | |
2187 | 2189 | | |
2188 | | - | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
2189 | 2193 | | |
2190 | 2194 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
43 | 59 | | |
44 | 60 | | |
45 | 61 | | |
| |||
106 | 122 | | |
107 | 123 | | |
108 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
109 | 140 | | |
110 | 141 | | |
111 | 142 | | |
| |||
141 | 172 | | |
142 | 173 | | |
143 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
144 | 190 | | |
145 | 191 | | |
146 | 192 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2085 | 2085 | | |
2086 | 2086 | | |
2087 | 2087 | | |
2088 | | - | |
| 2088 | + | |
2089 | 2089 | | |
2090 | 2090 | | |
2091 | 2091 | | |
| |||
2155 | 2155 | | |
2156 | 2156 | | |
2157 | 2157 | | |
2158 | | - | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
2159 | 2161 | | |
2160 | 2162 | | |
2161 | 2163 | | |
2162 | 2164 | | |
2163 | | - | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
2164 | 2168 | | |
2165 | 2169 | | |
2166 | 2170 | | |
| |||
0 commit comments