Skip to content

Commit 944af2a

Browse files
authored
ref(utils): Use type predicates for isError and isString (#4757)
This restores part of the work done in #4124, which then got reverted in #4149. The problem there was the predicates for `DOMError` and `DOMException`, both of which only exist in a browser context. This restores the predicates for `isError` and `isString`, which should be safe, because both `Error` and `string` exist in both browser and node contexts.
1 parent 1d03b15 commit 944af2a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/utils/src/is.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const objectToString = Object.prototype.toString;
1313
* @param wat A value to be checked.
1414
* @returns A boolean representing the result.
1515
*/
16-
export function isError(wat: unknown): boolean {
16+
export function isError(wat: unknown): wat is Error {
1717
switch (objectToString.call(wat)) {
1818
case '[object Error]':
1919
case '[object Exception]':
@@ -68,7 +68,7 @@ export function isDOMException(wat: unknown): boolean {
6868
* @param wat A value to be checked.
6969
* @returns A boolean representing the result.
7070
*/
71-
export function isString(wat: unknown): boolean {
71+
export function isString(wat: unknown): wat is string {
7272
return isBuiltin(wat, 'String');
7373
}
7474

0 commit comments

Comments
 (0)