diff --git a/index.d.ts b/index.d.ts index 708737b..36d7e20 100644 --- a/index.d.ts +++ b/index.d.ts @@ -21,8 +21,10 @@ importFresh('./foo')(); importFresh('./foo')(); //=> 1 + +const foo = importFresh('./foo'); ``` */ -declare function importFresh(moduleId: string): unknown; +declare function importFresh(moduleId: string): T; export = importFresh; diff --git a/index.test-d.ts b/index.test-d.ts index 8422444..abc006e 100644 --- a/index.test-d.ts +++ b/index.test-d.ts @@ -1,5 +1,12 @@ import {expectType, expectError} from 'tsd'; import importFresh = require('.'); +import path = require('path'); expectType(importFresh('hello')); expectError(importFresh()); + +expectType<(moduleId: string) => {}>(importFresh<(moduleId: string) => {}>('hello')); +expectType(importFresh('path')); + +const foo = importFresh('path'); +expectType(foo);