fix(timer): setTimeout/setInterval support for boolean period (#7569)

* Fix setTimeout/setInterval can't be called with boolean period

* Add typings and a test

* Revert typings

* Ignore the wrong type
This commit is contained in:
Bundyo (Kamen Bundev)
2019-08-02 16:06:03 +03:00
committed by Alexander Vakrilov
parent 78058087c8
commit a569bb2931
3 changed files with 26 additions and 0 deletions

View File

@@ -16,6 +16,9 @@ function createHandlerAndGetId(): number {
}
export function setTimeout(callback: Function, milliseconds = 0, ...args): number {
// Cast to Number
milliseconds += 0;
const id = createHandlerAndGetId();
const invoke = () => callback(...args);
const zoneBound = zonedCallback(invoke);
@@ -48,6 +51,9 @@ export function clearTimeout(id: number): void {
}
export function setInterval(callback: Function, milliseconds = 0, ...args): number {
// Cast to Number
milliseconds += 0;
const id = createHandlerAndGetId();
const handler = timeoutHandler;
const invoke = () => callback(...args);