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
commit a186f2edf2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 0 deletions

13
types/when-dom-ready/index.d.ts vendored Normal file
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>;
}

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"
]
}

View File

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

View File

@ -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>