wardens 0.5.0 → 0.5.1-rc.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/src/__tests__/types.test-d.ts +14 -1
- package/src/types.ts +4 -3
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { create, ResourceHandle } from '../';
|
1
|
+
import { create, ResourceContext, ResourceHandle } from '../';
|
2
2
|
|
3
3
|
describe('Utility types', () => {
|
4
4
|
describe('ResourceHandle', () => {
|
@@ -15,5 +15,18 @@ describe('Utility types', () => {
|
|
15
15
|
hello: 'world',
|
16
16
|
});
|
17
17
|
});
|
18
|
+
|
19
|
+
it('infers the type when the value comes from a parameter', async () => {
|
20
|
+
async function Test(_ctx: ResourceContext, value: { count: number }) {
|
21
|
+
return {
|
22
|
+
value,
|
23
|
+
};
|
24
|
+
}
|
25
|
+
|
26
|
+
const test = await create(Test, { count: 2 });
|
27
|
+
expectTypeOf(test).toEqualTypeOf<ResourceHandle<typeof Test>>({
|
28
|
+
count: 2,
|
29
|
+
});
|
30
|
+
});
|
18
31
|
});
|
19
32
|
});
|
package/src/types.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
1
2
|
import type ResourceContext from './resource-context';
|
2
3
|
|
3
4
|
/**
|
@@ -25,6 +26,6 @@ export interface Resource<Value extends object> {
|
|
25
26
|
}
|
26
27
|
|
27
28
|
/** The `value` type returned when creating a resource. */
|
28
|
-
export type ResourceHandle<
|
29
|
-
|
30
|
-
>['value'];
|
29
|
+
export type ResourceHandle<
|
30
|
+
Factory extends ParametrizedResourceFactory<object, Array<any>>,
|
31
|
+
> = Awaited<ReturnType<Factory>>['value'];
|