-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rewards for linena rseth (#1490)
* Add rewards for linena rseth * Fix typo
- Loading branch information
1 parent
89fa93d
commit 32400e2
Showing
3 changed files
with
120 additions
and
44 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,33 @@ | ||
/** | ||
* Helper function for exhaustive checks of discriminated unions. | ||
* https://basarat.gitbooks.io/typescript/docs/types/discriminated-unions.html | ||
* | ||
* @example | ||
* | ||
* type A = {type: 'a'}; | ||
* type B = {type: 'b'}; | ||
* type Union = A | B; | ||
* | ||
* function doSomething(arg: Union) { | ||
* if (arg.type === 'a') { | ||
* return something; | ||
* } | ||
* | ||
* if (arg.type === 'b') { | ||
* return somethingElse; | ||
* } | ||
* | ||
* // TS will error if there are other types in the union | ||
* // Will throw an Error when called at runtime. | ||
* // Use `assertNever(arg, true)` instead to fail silently. | ||
* return assertNever(arg); | ||
* } | ||
*/ export function assertNever(value: never, noThrow?: boolean): never { | ||
if (noThrow) { | ||
return value; | ||
} | ||
|
||
throw new Error( | ||
`Unhandled discriminated union member: ${JSON.stringify(value)}`, | ||
); | ||
} |
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