From 590463bd4a8d71330ab808774b63dd6b366bba1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=BF=B7=E6=B8=A1?= Date: Thu, 29 Aug 2019 22:57:09 +0800 Subject: setTimeout's params should not be bigint (#2834) --- js/timers.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'js/timers.ts') diff --git a/js/timers.ts b/js/timers.ts index 079e779c4..d12205317 100644 --- a/js/timers.ts +++ b/js/timers.ts @@ -179,6 +179,12 @@ function checkThis(thisArg: unknown): void { } } +function checkBigInt(n: unknown): void { + if (typeof n === "bigint") { + throw new TypeError("Cannot convert a BigInt value to a number"); + } +} + function setTimer( cb: (...args: Args) => void, delay: number, @@ -224,6 +230,7 @@ export function setTimeout( delay: number = 0, ...args: Args ): number { + checkBigInt(delay); // @ts-ignore checkThis(this); return setTimer(cb, delay, args, false); @@ -235,6 +242,7 @@ export function setInterval( delay: number = 0, ...args: Args ): number { + checkBigInt(delay); // @ts-ignore checkThis(this); return setTimer(cb, delay, args, true); -- cgit v1.2.3