diff --git a/package.json b/package.json index 74753bc..b377e66 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ "scripts": { "build": "rollup --config rollup.config.ts --configPlugin typescript", "lint": "eslint .", - "test": "npm run lint && npm run coverage", + "test": "npm run lint && tsc --noEmit && npm run coverage", "open-coverage": "open coverage/lcov-report/index.ts.html", "publish-coverage": "npm run coverage && coveralls < coverage/lcov.info", "coverage": "vitest run --coverage" diff --git a/rollup.config.ts b/rollup.config.ts index b3ef722..bd79c1d 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -5,5 +5,5 @@ export default { output: { file: 'dist/index.mjs', }, - plugins: [typescript()], + plugins: [typescript({ include: ['src/index.ts'] })], } diff --git a/src/index.test.ts b/src/index.test.ts index 295005b..acf7e9d 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -1430,4 +1430,19 @@ describe('memoize-fs', () => { assert.ok(throws) }) }) + + describe('typing', () => { + it('should not double-wrap Promise>', async () => { + const cachePath = FIXTURE_CACHE + const memoize = memoizeFs({ cachePath }) + + const syncFunction: () => number= () => 1; + const asyncFunction: () => Promise = async () => 1; + + let memFn: () => Promise; + memFn = await memoize.fn(syncFunction); + memFn = await memoize.fn(asyncFunction); + memFn; + }) + }) }) diff --git a/tsconfig.json b/tsconfig.json index e50b4cc..42fa558 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -6,7 +6,8 @@ "strict": true, "moduleResolution": "node", "outDir": "dist", - "declaration": true + "declaration": true, + "skipLibCheck": true }, - "include": ["src/index.ts"] + "include": ["src"] }