mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
fix build-effect error (#11496)
This commit is contained in:
@@ -30,11 +30,11 @@ declare class FinalizationRegistry {
|
||||
const targetSymbol = Symbol('[[target]]');
|
||||
|
||||
class GarbageCollectionManager {
|
||||
private _finalizationRegistry: FinalizationRegistry | null = EDITOR ? new FinalizationRegistry(this.finalizationRegistryCallback.bind(this)) : null;
|
||||
private _finalizationRegistry: FinalizationRegistry | null = EDITOR && FinalizationRegistry ? new FinalizationRegistry(this.finalizationRegistryCallback.bind(this)) : null;
|
||||
private _gcObjects: WeakMap<any, GCObject> = new WeakMap();
|
||||
|
||||
public registerGCObject (gcObject: GCObject): GCObject {
|
||||
if (EDITOR) {
|
||||
if (EDITOR && this._finalizationRegistry) {
|
||||
const token = {};
|
||||
const proxy = new Proxy(gcObject, {
|
||||
get (target, property, receiver) {
|
||||
@@ -57,7 +57,7 @@ class GarbageCollectionManager {
|
||||
},
|
||||
});
|
||||
this._gcObjects.set(token, gcObject);
|
||||
this._finalizationRegistry!.register(proxy, token, token);
|
||||
this._finalizationRegistry.register(proxy, token, token);
|
||||
return proxy;
|
||||
} else {
|
||||
return gcObject;
|
||||
|
||||
Reference in New Issue
Block a user