🚨 fix tsc error (#1292)

This commit is contained in:
Kuitos 2021-03-01 18:41:42 +08:00 committed by GitHub
parent c79907d4c2
commit 0f3c195b4c

View File

@ -12,7 +12,7 @@ import { getTargetValue, setCurrentRunningSandboxProxy } from './common';
* fastest(at most time) unique array method * fastest(at most time) unique array method
* @see https://jsperf.com/array-filter-unique/30 * @see https://jsperf.com/array-filter-unique/30
*/ */
function uniq(array: PropertyKey[]) { function uniq(array: Array<string | symbol>) {
return array.filter(function filter(this: PropertyKey[], element) { return array.filter(function filter(this: PropertyKey[], element) {
return element in this ? false : ((this as any)[element] = true); return element in this ? false : ((this as any)[element] = true);
}, Object.create(null)); }, Object.create(null));
@ -303,9 +303,8 @@ export default class ProxySandbox implements SandBox {
}, },
// trap to support iterator with sandbox // trap to support iterator with sandbox
ownKeys(target: FakeWindow): PropertyKey[] { ownKeys(target: FakeWindow): ArrayLike<string | symbol> {
const keys = uniq(Reflect.ownKeys(rawWindow).concat(Reflect.ownKeys(target))); return uniq(Reflect.ownKeys(rawWindow).concat(Reflect.ownKeys(target)));
return keys;
}, },
defineProperty(target: Window, p: PropertyKey, attributes: PropertyDescriptor): boolean { defineProperty(target: Window, p: PropertyKey, attributes: PropertyDescriptor): boolean {