diff --git a/types/freshy/freshy-tests.ts b/types/freshy/freshy-tests.ts new file mode 100644 index 0000000000..406791d0eb --- /dev/null +++ b/types/freshy/freshy-tests.ts @@ -0,0 +1,21 @@ +import { unload, reload, freshy } from 'freshy'; +import minimist = require('minimist'); + +declare function require(x: string): any; + +unload('minimist'); // $ExpectType boolean + +const reloaded = reload('minimist'); // $ExpectType any +minimist === reloaded; // false + +const freshlyLoaded = freshy('minimist'); // $ExpectType any +minimist === freshlyLoaded; // false + +let alsofresh: any; +// $ExpectType any +const fresh = freshy('minimist', (fresh) => { + alsofresh = require('minimist'); + fresh === alsofresh; // true +}); +minimist === fresh; // false +fresh === alsofresh; // true diff --git a/types/freshy/index.d.ts b/types/freshy/index.d.ts new file mode 100644 index 0000000000..93b424143a --- /dev/null +++ b/types/freshy/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for freshy 1.0 +// Project: https://github.com/krakenjs/freshy#readme +// Definitions by: Nikita Volodin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function unload(module: string): boolean; +export function reload(module: string): any; +export function freshy(module: string, cb?: (module: any) => any): any; diff --git a/types/freshy/tsconfig.json b/types/freshy/tsconfig.json new file mode 100644 index 0000000000..7cc3f4d9f4 --- /dev/null +++ b/types/freshy/tsconfig.json @@ -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", + "freshy-tests.ts" + ] +} diff --git a/types/freshy/tslint.json b/types/freshy/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/freshy/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }