Skip to content

Commit

Permalink
feat: enhance isCError & isWError methods with type predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
jdpnielsen committed Sep 22, 2020
1 parent 6131d13 commit 8a4037d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lib/cerror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class CError extends Error {
};
}

public static isCError(obj: unknown): boolean {
public static isCError(obj: unknown): obj is CError {
return (obj as {[CERROR_SYMBOL]?: boolean})?.[CERROR_SYMBOL] != null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/werror.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class WError extends CError {
}
}

public static isWError(obj: unknown): boolean {
public static isWError(obj: unknown): obj is WError {
return (obj as { [WERROR_SYMBOL]?: boolean })?.[WERROR_SYMBOL] != null;
}
}
Expand Down

0 comments on commit 8a4037d

Please sign in to comment.