🤖 Merge PR #46642 feat(long-timeout): new type definition by @MatthiasKunnen

* feat(long-timeout): new type definition

* fix(long-timeout): remove export as namespace

long-timeout does not have a UMD wrapper.
This commit is contained in:
Matthias Kunnen 2020-08-13 01:38:28 +02:00 committed by GitHub
parent c6531e7ee6
commit c7a768fca6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 0 deletions

28
types/long-timeout/index.d.ts vendored Normal file
View File

@ -0,0 +1,28 @@
// Type definitions for long-timeout 0.1
// Project: https://github.com/tellnes/long-timeout
// Definitions by: Matthias Kunnen <https://github.com/MatthiasKunnen>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export type Listener = (...args: any[]) => void;
export class Timeout {
after: number;
close: () => void;
listener: Listener;
ref: () => void;
start: () => void;
unref: () => void;
unreffed: boolean;
constructor(listener: Listener, ms: number);
}
export type Interval = Timeout;
export function clearInterval(timer: Interval): void;
export function clearTimeout(timer: Timeout): void;
export function setInterval(listener: Listener, ms: number): Interval;
export function setTimeout(listener: Listener, ms: number): Timeout;

View File

@ -0,0 +1,15 @@
import * as lt from 'long-timeout';
const interval = lt.setInterval(() => {
// Do things
}, 4000);
interval.close();
lt.clearInterval(interval);
const timeout = lt.setTimeout(() => {
// Do things
}, 50);
lt.clearTimeout(timeout);

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"long-timeout-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }