1 /** List of native JavaScript error types to distinguish from
2 * WASM-generated errors. Used to identify errors originating
3 * from the JavaScript runtime vs errors coming from WASM. */
4 const NATIVE_JS_ERROR_TYPES = [
5 typeof TypeError !== 'undefined' ? TypeError : null,
6 typeof ReferenceError !== 'undefined' ? ReferenceError : null,
7 typeof SyntaxError !== 'undefined' ? SyntaxError : null,
8 typeof RangeError !== 'undefined' ? RangeError : null,
9 typeof URIError !== 'undefined' ? URIError : null,
10 typeof EvalError !== 'undefined' ? EvalError : null,
11 ].filter((errorType): errorType is ErrorConstructor => errorType !== null);
13 export const isNativeJSError = (error: unknown): boolean =>
14 NATIVE_JS_ERROR_TYPES.some((errorType) => error instanceof errorType);