-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Adjust fail method and ActionFailure type
- add ActionFailure interface and use that publicly instead of the class. Prevents the false impression that you could do "instanceof" on the return type, fixes #10361 - add uniqueSymbol to ActionFailure instance so we can distinguish it from a regular return with the same shape - fix setup to actually run test/types
- Loading branch information
1 parent
608e3ef
commit bf0282b
Showing
7 changed files
with
51 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@sveltejs/kit': patch | ||
--- | ||
|
||
fix: Adjust fail method and ActionFailure type |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,12 @@ | ||
import Kit, { Deferred } from '@sveltejs/kit'; | ||
import * as Kit from '@sveltejs/kit'; | ||
|
||
// Test: Return types inferred correctly and transformed into a union | ||
type LoadReturn1 = { success: true } | { message: Promise<string> }; | ||
type LoadReturn1 = | ||
| { success: true; message?: undefined } | ||
| { success?: undefined; message: string }; | ||
|
||
let result1: Kit.AwaitedProperties<LoadReturn1> = null as any; | ||
let result1: Kit.LoadProperties<LoadReturn1> = null as any; | ||
result1.message = ''; | ||
result1.success = true; | ||
// @ts-expect-error - cannot both be present at the same time | ||
result1 = { message: '', success: true }; | ||
|
||
// Test: Return types keep promise for Deferred | ||
type LoadReturn2 = { success: true } | Deferred<{ message: Promise<string>; eager: true }>; | ||
|
||
let result2: Kit.AwaitedProperties<LoadReturn2> = null as any; | ||
result2.message = Promise.resolve(''); | ||
result2.eager = true; | ||
result2.success = true; | ||
// @ts-expect-error - cannot both be present at the same time | ||
result2 = { message: '', success: true }; |