Commit 93584d1
fix: use Promise<Response> for async kit handler return types (#2966)
* fix: use Promise<Response> return type for async kit handlers
When svelte-check adds type annotations to SvelteKit route handlers
(GET, POST, etc.), it was using `Response | Promise<Response>` as the
return type for all functions regardless of whether they were async.
TypeScript requires async functions to return `Promise<T>`, not
`T | Promise<T>` (TS1064). This caused false positives in
`--incremental` mode where tsc runs on the generated files directly.
The fix checks if the function has an async modifier and, if so,
extracts just the `Promise<Response>` part of the return type union.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* style: format sveltekit.ts with prettier
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix async kit handler return types
Updated async kit handler return types to use Promise<Response>.
* style: format changeset
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor: use asyncReturnType parameter instead of string splitting
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent e7168a9 commit 93584d1
File tree
5 files changed
+37
-4
lines changed- .changeset
- packages
- svelte-check/test-success/src/routes
- svelte2tsx
- src/helpers
- test/helpers
5 files changed
+37
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
283 | 283 | | |
284 | 284 | | |
285 | 285 | | |
286 | | - | |
| 286 | + | |
| 287 | + | |
287 | 288 | | |
288 | 289 | | |
289 | 290 | | |
| |||
476 | 477 | | |
477 | 478 | | |
478 | 479 | | |
479 | | - | |
| 480 | + | |
| 481 | + | |
480 | 482 | | |
481 | 483 | | |
482 | 484 | | |
| |||
485 | 487 | | |
486 | 488 | | |
487 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
488 | 494 | | |
489 | 495 | | |
490 | 496 | | |
491 | 497 | | |
492 | | - | |
| 498 | + | |
493 | 499 | | |
494 | 500 | | |
495 | 501 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
75 | 83 | | |
76 | 84 | | |
77 | 85 | | |
| |||
0 commit comments