chore: replace __proto__ by getPrototypeOf (#17386)
This commit is contained in:
Родитель
df143031e7
Коммит
840a1f6436
|
@ -71,6 +71,7 @@ module.exports = {
|
|||
"valid-typeof": 2,
|
||||
"no-implicit-globals": [2],
|
||||
"no-unused-expressions": [2, { "allowShortCircuit": true, "allowTernary": true, "allowTaggedTemplates": true}],
|
||||
"no-proto": 2,
|
||||
|
||||
// es2015 features
|
||||
"require-yield": 2,
|
||||
|
|
|
@ -184,5 +184,6 @@ function isURL(obj: any): obj is URL {
|
|||
}
|
||||
|
||||
function isError(obj: any): obj is Error {
|
||||
return obj instanceof Error || obj?.__proto__?.name === 'Error' || (obj?.__proto__ && isError(obj.__proto__));
|
||||
const proto = obj ? Object.getPrototypeOf(obj) : null;
|
||||
return obj instanceof Error || proto?.name === 'Error' || (proto && isError(proto));
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ export function source() {
|
|||
|
||||
function isError(obj: any): obj is Error {
|
||||
try {
|
||||
return obj instanceof Error || (obj && obj.__proto__ && obj.__proto__.name === 'Error');
|
||||
return obj instanceof Error || (obj && Object.getPrototypeOf(obj)?.name === 'Error');
|
||||
} catch (error) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ export function isObject(obj: any): obj is NonNullable<object> {
|
|||
}
|
||||
|
||||
export function isError(obj: any): obj is Error {
|
||||
return obj instanceof Error || (obj && obj.__proto__ && obj.__proto__.name === 'Error');
|
||||
return obj instanceof Error || (obj && Object.getPrototypeOf(obj)?.name === 'Error');
|
||||
}
|
||||
|
||||
const debugEnv = getFromENV('PWDEBUG') || '';
|
||||
|
|
Загрузка…
Ссылка в новой задаче