feat(types/freshy): types for new module freshy

This commit is contained in:
Nikita Volodin [Никита Володин]
2018-05-05 23:15:03 -04:00
parent e94c84bd5e
commit 486a5dc69f
4 changed files with 59 additions and 0 deletions
+27
View File
@@ -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
+8
View File
@@ -0,0 +1,8 @@
// Type definitions for freshy 1.0
// Project: https://github.com/krakenjs/freshy#readme
// Definitions by: Nikita Volodin <https://github.com/qlonik>
// 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;
+23
View File
@@ -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"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }