mirror of
https://github.com/orionprotocol/sdk.git
synced 2026-03-26 07:37:44 +03:00
Update isWithCode - allow string code
This commit is contained in:
@@ -3,7 +3,7 @@ type WithReason = {
|
||||
}
|
||||
|
||||
type WithCodeError = Error & {
|
||||
code: number;
|
||||
code: number | string;
|
||||
}
|
||||
|
||||
type WithMessage = {
|
||||
@@ -41,9 +41,9 @@ export function hasProp<T extends Record<string, unknown>, K extends PropertyKey
|
||||
}
|
||||
|
||||
export function isWithCode(candidate: unknown): candidate is WithCodeError {
|
||||
if (!isUnknownObject(candidate)) return false;
|
||||
const hasCodeProperty = hasProp(candidate, 'code') && typeof candidate.code === 'number';
|
||||
return hasCodeProperty;
|
||||
if (!isUnknownObject(candidate) || !hasProp(candidate, 'code')) return false;
|
||||
const type = typeof candidate.code;
|
||||
return type === 'number' || type === 'string';
|
||||
}
|
||||
|
||||
export function isWithReason(candidate: unknown): candidate is WithReason {
|
||||
|
||||
Reference in New Issue
Block a user