Skip to content

Commit

Permalink
Test EnsurePromise<T> typing
Browse files Browse the repository at this point in the history
  • Loading branch information
joliss authored and borisdiakur committed Mar 1, 2024
1 parent 91a3f84 commit 8a872fb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion rollup.config.ts
Expand Up @@ -5,5 +5,5 @@ export default {
output: {
file: 'dist/index.mjs',
},
plugins: [typescript()],
plugins: [typescript({ include: ['src/index.ts'] })],
}
15 changes: 15 additions & 0 deletions src/index.test.ts
Expand Up @@ -1430,4 +1430,19 @@ describe('memoize-fs', () => {
assert.ok(throws)
})
})

describe('typing', () => {
it('should not double-wrap Promise<Promise<T>>', async () => {
const cachePath = FIXTURE_CACHE
const memoize = memoizeFs({ cachePath })

const syncFunction: () => number= () => 1;
const asyncFunction: () => Promise<number> = async () => 1;

let memFn: () => Promise<number>;
memFn = await memoize.fn(syncFunction);
memFn = await memoize.fn(asyncFunction);
memFn;
})
})
})
5 changes: 3 additions & 2 deletions tsconfig.json
Expand Up @@ -6,7 +6,8 @@
"strict": true,
"moduleResolution": "node",
"outDir": "dist",
"declaration": true
"declaration": true,
"skipLibCheck": true
},
"include": ["src/index.ts"]
"include": ["src"]
}

0 comments on commit 8a872fb

Please sign in to comment.