mirror of
https://github.com/denoland/deno.git
synced 2025-09-27 12:49:10 +00:00
clearTimeout's params should not be bigint (#2838)
This commit is contained in:
parent
c370f749b2
commit
65fa2b810b
2 changed files with 17 additions and 0 deletions
|
@ -262,6 +262,7 @@ function clearTimer(id: number): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function clearTimeout(id: number = 0): void {
|
export function clearTimeout(id: number = 0): void {
|
||||||
|
checkBigInt(id);
|
||||||
if (id === 0) {
|
if (id === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -269,6 +270,7 @@ export function clearTimeout(id: number = 0): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function clearInterval(id: number = 0): void {
|
export function clearInterval(id: number = 0): void {
|
||||||
|
checkBigInt(id);
|
||||||
if (id === 0) {
|
if (id === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -259,6 +259,21 @@ test(function setTimeoutShouldThrowWithBigint(): void {
|
||||||
assertEquals(hasThrown, 2);
|
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 {
|
test(function testFunctionName(): void {
|
||||||
assertEquals(clearTimeout.name, "clearTimeout");
|
assertEquals(clearTimeout.name, "clearTimeout");
|
||||||
assertEquals(clearInterval.name, "clearInterval");
|
assertEquals(clearInterval.name, "clearInterval");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue