-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(if): properly throw warnings in dev mode
- Loading branch information
Showing
7 changed files
with
41 additions
and
43 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
This file was deleted.
Oops, something went wrong.
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,27 @@ | ||
/** | ||
* Handles errors by throwing them to the console. | ||
* `__DEV__` is replaced by tsdx using {@link https://www.npmjs.com/package/babel-plugin-dev-expression babel-plugin-dev-expressions} | ||
* which will ensure this entire throw is not present in production | ||
* @param condition The condition to check | ||
* @param message The message to throw if `condition` resolves to `true` | ||
*/ | ||
export function tinyWarning(condition: boolean, message: string): asserts condition { | ||
if (__DEV__) { | ||
if (condition) { | ||
// check console for IE9 support which provides console | ||
// only with open devtools | ||
|
||
if (typeof console !== 'undefined') { | ||
console.warn(message); | ||
} | ||
|
||
// Throwing an error and catching it immediately to improve debugging | ||
// Users can utilize 'pause on caught exceptions' to get into this throw | ||
try { | ||
throw new Error(message); | ||
} catch (x) { | ||
// noop | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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