From 486a5dc69f3fa7da3f750b0b54a729565e86b9ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikita=20Volodin=20=5B=D0=9D=D0=B8=D0=BA=D0=B8=D1=82=D0=B0?= =?UTF-8?q?=20=D0=92=D0=BE=D0=BB=D0=BE=D0=B4=D0=B8=D0=BD=5D?= Date: Sat, 5 May 2018 23:15:03 -0400 Subject: [PATCH] feat(types/freshy): types for new module freshy --- types/freshy/freshy-tests.ts | 27 +++++++++++++++++++++++++++ types/freshy/index.d.ts | 8 ++++++++ types/freshy/tsconfig.json | 23 +++++++++++++++++++++++ types/freshy/tslint.json | 1 + 4 files changed, 59 insertions(+) create mode 100644 types/freshy/freshy-tests.ts create mode 100644 types/freshy/index.d.ts create mode 100644 types/freshy/tsconfig.json create mode 100644 types/freshy/tslint.json diff --git a/types/freshy/freshy-tests.ts b/types/freshy/freshy-tests.ts new file mode 100644 index 0000000000..1134489d77 --- /dev/null +++ b/types/freshy/freshy-tests.ts @@ -0,0 +1,27 @@ +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 +// $ExpectType boolean +minimist === reloaded; // false + +const freshlyLoaded = freshy('minimist'); // $ExpectType any +// $ExpectType boolean +minimist === freshlyLoaded; // false + +let alsofresh: any; +// $ExpectType any +const fresh = freshy('minimist', (fresh) => { + alsofresh = require('minimist'); + + // $ExpectType boolean + fresh === alsofresh; // true +}); +// $ExpectType boolean +minimist === fresh; // false +// $ExpectType boolean +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" }