little-loader types (#36127)

* adding types for little-loader

* adding support files

* use 4 spaces

* export directly

* export default?

* I'm so confused.

* going back to original. giving up.

* missing version and ;

* trying to just export a function one more time...

* remove export?

* *sigh*

* updating import on test

* context is optional

* update to deal with options case.

* remove unnecessary generic?
This commit is contained in:
Chris Drackett
2019-06-24 13:00:42 -07:00
committed by Daniel Rosenwasser
parent d54c178c24
commit af9ceddfdf
4 changed files with 43 additions and 0 deletions

23
types/little-loader/index.d.ts vendored Normal file
View File

@@ -0,0 +1,23 @@
// Type definitions for little-loader 0.2
// Project: https://github.com/walmartlabs/little-loader
// Definitions by: Chris Drackett <https://github.com/chrisdrackett>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Options {
context?: any;
setup?: (this: any, script: any) => void;
callback?: (this: any, err: string) => void;
}
declare function loader(
module: string,
callback?: (this: any, err: string) => void,
context?: any
): void;
declare function loader(
module: string,
options?: Options
): void;
export = loader;

View File

@@ -0,0 +1,3 @@
import load = require("little-loader");
load("http://google.com/test.js", () => console.log("loaded!"), ""); // $ExpectType void

View File

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

View File

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