Skip to content

Commit

Permalink
Merge pull request #6 from raskyer/main-1
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber authored Aug 17, 2023
2 parents 376d56e + 586a369 commit 79b569a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "combine-promises",
"author": "slorber",
"version": "1.1.0",
"version": "1.2.0",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
6 changes: 2 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
type UnwrapPromise<P extends Promise<unknown>> = P extends PromiseLike<infer V>
? V
: never;
type UnwrapPromise<P extends unknown> = P extends PromiseLike<infer V> ? V : P;

type Input = Record<string | number | symbol, Promise<unknown>>;
type Input = Record<string | number | symbol, unknown>;

type Result<Obj extends Input> = {
[P in keyof Obj]: UnwrapPromise<Obj[P]>;
Expand Down
4 changes: 1 addition & 3 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,9 @@ describe('combinePromises', () => {
expect(result).toEqual({ user: createUser(1), company: createCompany(2) });
});

it('can handle sync values, but TS errors', async () => {
// @ts-expect-error: "company" value should be async/Promise
it('can handle sync values', async () => {
const result: { user: User; company: Company } = await combinePromises({
user: fetchUser(1),
// @ts-expect-error: "company" value should be async/Promise
company: createCompany(2),
});
expect(result).toEqual({ user: createUser(1), company: createCompany(2) });
Expand Down

0 comments on commit 79b569a

Please sign in to comment.