1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00

clearTimeout's params should not be bigint (#2838)

This commit is contained in:
迷渡 2019-08-30 23:51:53 +08:00 committed by Ryan Dahl
parent c370f749b2
commit 65fa2b810b
2 changed files with 17 additions and 0 deletions

View file

@ -262,6 +262,7 @@ function clearTimer(id: number): void {
}
export function clearTimeout(id: number = 0): void {
checkBigInt(id);
if (id === 0) {
return;
}
@ -269,6 +270,7 @@ export function clearTimeout(id: number = 0): void {
}
export function clearInterval(id: number = 0): void {
checkBigInt(id);
if (id === 0) {
return;
}

View file

@ -259,6 +259,21 @@ test(function setTimeoutShouldThrowWithBigint(): void {
assertEquals(hasThrown, 2);
});
test(function clearTimeoutShouldThrowWithBigint(): void {
let hasThrown = 0;
try {
clearTimeout((1n as unknown) as number);
hasThrown = 1;
} catch (err) {
if (err instanceof TypeError) {
hasThrown = 2;
} else {
hasThrown = 3;
}
}
assertEquals(hasThrown, 2);
});
test(function testFunctionName(): void {
assertEquals(clearTimeout.name, "clearTimeout");
assertEquals(clearInterval.name, "clearInterval");