Fix editor extendable (#8782)

* Fix editor extendable

* Update editor-extendable.ts

* Update editor-extendable.ts
This commit is contained in:
Leslie Leigh (李的序)
2021-06-08 11:27:54 +08:00
committed by GitHub
parent dbfcdd04e7
commit b8bed774df
+3 -3
View File
@@ -21,7 +21,7 @@ export function EditorExtendableMixin<T> (Base: new (...args: any[]) => T, class
/**
* Class which implements the `EditorExtendableObject` interface.
*/
export const EditorExtendable = editorExtendableInternal(Object);
export const EditorExtendable = editorExtendableInternal();
export type EditorExtendable = InstanceType<typeof EditorExtendable>;
@@ -30,7 +30,7 @@ function editorExtendableInternal<T> (Base?: (new (...args: any[]) => T), classN
type ResultType = new (...args: any[]) => (T & EditorExtendableObject);
if (!EDITOR) {
return Base as unknown as ResultType;
return (Base ?? Object) as unknown as ResultType;
}
let name: string;
@@ -43,7 +43,7 @@ function editorExtendableInternal<T> (Base?: (new (...args: any[]) => T), classN
if (baseName) {
name = `cc.EditorExtendable/${baseName}`;
} else {
throw new Error(`You should supply a class name to EditorExtendable.`);
throw new Error(`You should supply a class name to EditorExtendable when mixin with ${Base.name}.`);
}
}