mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 14:57:10 +00:00
Merge pull request #31649 from BendingBender/macrotask
[macrotask] Add types
This commit is contained in:
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for macrotask 3.0
|
||||
// Project: https://github.com/calvinmetcalf/macrotask#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
export as namespace macrotask;
|
||||
|
||||
export function run<TArgs extends any[]>(
|
||||
task: (...args: TArgs) => void,
|
||||
...args: TArgs
|
||||
): CancelToken;
|
||||
|
||||
export function clear(cancel: CancelToken): void;
|
||||
|
||||
export class CancelToken {
|
||||
// needed for TS to not accept just any object, only instances of CancelToken
|
||||
private __cancel__prop: 'imaginary';
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { run, clear } from 'macrotask';
|
||||
|
||||
const token = run(() => {});
|
||||
run(arg1 => {}); // $ExpectError
|
||||
|
||||
run(
|
||||
(arg1, arg2) => {
|
||||
arg1; // $ExpectType string
|
||||
arg2; // $ExpectType number
|
||||
},
|
||||
'foo',
|
||||
1
|
||||
);
|
||||
// $ExpectError
|
||||
run((arg1, arg2) => {}, 'foo');
|
||||
// $ExpectError
|
||||
run((arg1: string, arg2: number) => {}, 'foo', 'bar');
|
||||
|
||||
clear(token);
|
||||
clear({}); // $ExpectError
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"macrotask-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user