-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for removing functions named
invariant
and assertions f…
…rom `tiny-invariant` (#966)
- Loading branch information
Showing
7 changed files
with
68 additions
and
187 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,18 @@ | ||
--- | ||
'sku': minor | ||
--- | ||
|
||
Add support for removing assertion functions named `invariant` and assertions from the `tiny-invariant` library, a lightweight alternative to `assert` | ||
|
||
**EXAMPLE USAGE**: | ||
|
||
```tsx | ||
import React from 'react'; | ||
import invariant from 'tiny-invariant'; | ||
|
||
export const Rating = ({ rating }: { rating: number }) => { | ||
invariant(rating >= 0 && rating <= 5, 'Rating must be between 0 and 5'); | ||
|
||
return <div>...</div>; | ||
}; | ||
``` |
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,7 +1,9 @@ | ||
import assert from 'assert'; | ||
import invariant from 'tiny-invariant'; | ||
|
||
export default () => { | ||
assert(false, 'Should be true'); | ||
invariant(false, 'Should be true'); | ||
|
||
return <div>It rendered without throwing an assertion error</div>; | ||
}; |
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
Oops, something went wrong.