From 0f3c195b4c13fbde25f14ef4120d6afb13dfd507 Mon Sep 17 00:00:00 2001 From: Kuitos Date: Mon, 1 Mar 2021 18:41:42 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A8=20fix=20tsc=20error=20(#1292)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/sandbox/proxySandbox.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/sandbox/proxySandbox.ts b/src/sandbox/proxySandbox.ts index 50826bf..79c43bc 100644 --- a/src/sandbox/proxySandbox.ts +++ b/src/sandbox/proxySandbox.ts @@ -12,7 +12,7 @@ import { getTargetValue, setCurrentRunningSandboxProxy } from './common'; * fastest(at most time) unique array method * @see https://jsperf.com/array-filter-unique/30 */ -function uniq(array: PropertyKey[]) { +function uniq(array: Array) { return array.filter(function filter(this: PropertyKey[], element) { return element in this ? false : ((this as any)[element] = true); }, Object.create(null)); @@ -303,9 +303,8 @@ export default class ProxySandbox implements SandBox { }, // trap to support iterator with sandbox - ownKeys(target: FakeWindow): PropertyKey[] { - const keys = uniq(Reflect.ownKeys(rawWindow).concat(Reflect.ownKeys(target))); - return keys; + ownKeys(target: FakeWindow): ArrayLike { + return uniq(Reflect.ownKeys(rawWindow).concat(Reflect.ownKeys(target))); }, defineProperty(target: Window, p: PropertyKey, attributes: PropertyDescriptor): boolean {