From af9ceddfdf41895e2ef1cd9a21e3884caa5e81a9 Mon Sep 17 00:00:00 2001 From: Chris Drackett Date: Mon, 24 Jun 2019 13:00:42 -0700 Subject: [PATCH] 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? --- types/little-loader/index.d.ts | 23 ++++++++++++++++++++++ types/little-loader/little-loader-tests.ts | 3 +++ types/little-loader/tsconfig.json | 16 +++++++++++++++ types/little-loader/tslint.json | 1 + 4 files changed, 43 insertions(+) create mode 100644 types/little-loader/index.d.ts create mode 100644 types/little-loader/little-loader-tests.ts create mode 100644 types/little-loader/tsconfig.json create mode 100644 types/little-loader/tslint.json diff --git a/types/little-loader/index.d.ts b/types/little-loader/index.d.ts new file mode 100644 index 0000000000..eab91adc75 --- /dev/null +++ b/types/little-loader/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for little-loader 0.2 +// Project: https://github.com/walmartlabs/little-loader +// Definitions by: Chris Drackett +// 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; diff --git a/types/little-loader/little-loader-tests.ts b/types/little-loader/little-loader-tests.ts new file mode 100644 index 0000000000..1abbf5d2f0 --- /dev/null +++ b/types/little-loader/little-loader-tests.ts @@ -0,0 +1,3 @@ +import load = require("little-loader"); + +load("http://google.com/test.js", () => console.log("loaded!"), ""); // $ExpectType void diff --git a/types/little-loader/tsconfig.json b/types/little-loader/tsconfig.json new file mode 100644 index 0000000000..6fcf740298 --- /dev/null +++ b/types/little-loader/tsconfig.json @@ -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"] +} diff --git a/types/little-loader/tslint.json b/types/little-loader/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/little-loader/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }