Skip to content

Commit

Permalink
Fix the issue with the getClassName error under ES6
Browse files Browse the repository at this point in the history
  • Loading branch information
knoxHuang committed Sep 23, 2024
1 parent 919ed87 commit 54f60a5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cocos/core/utils/js-typed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,7 @@ export function getClassName (objOrCtor: any): string {
// for browsers which have name property in the constructor of the object, such as chrome
if (objOrCtor.name) {
ret = objOrCtor.name;
}
if (objOrCtor.toString) {
} else if (objOrCtor.toString) {
let arr;
const str = objOrCtor.toString();
if (str.charAt(0) === '[') {
Expand All @@ -261,7 +260,7 @@ export function getClassName (objOrCtor: any): string {
} else {
// str is function objectClass () {} for IE Firefox
// eslint-disable-next-line @typescript-eslint/prefer-regexp-exec
arr = /function\s*(\w+)/.exec(str);
arr = /^function\s*(\w+)/.exec(str);

Check failure on line 263 in cocos/core/utils/js-typed.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Unsafe argument of type `any` assigned to a parameter of type `string`
}
if (arr && arr.length === 2) {
ret = arr[1];
Expand Down

0 comments on commit 54f60a5

Please sign in to comment.