Merge pull request #32103 from BendingBender/when-dom-ready

[when-dom-ready] Add types
This commit is contained in:
Daniel Rosenwasser
2019-01-14 14:08:47 -08:00
committed by GitHub
4 changed files with 45 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
// Type definitions for when-dom-ready 1.2
// Project: https://github.com/lukechilds/when-dom-ready
// Definitions by: BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = whenDomReady;
declare function whenDomReady(document?: EventTarget): Promise<void>;
declare function whenDomReady(callback?: () => void, document?: EventTarget): Promise<void>;
declare namespace whenDomReady {
function resume<T>(document?: EventTarget): (value: T) => Promise<T>;
}
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"when-dom-ready-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
@@ -0,0 +1,7 @@
import whenDomReady = require('when-dom-ready');
whenDomReady(); // $ExpectType Promise<void>
whenDomReady(document); // $ExpectType Promise<void>
whenDomReady(() => {}, document); // $ExpectType Promise<void>
Promise.resolve('foo').then(whenDomReady.resume<string>(document)); // $ExpectType Promise<string>