Skip to content

Commit e7cb31f

Browse files
authored
Merge pull request #8497 from marmelab/fix-usecontext-type
[TypeScript] Fix return type of `useShowContext`, `useEditContext`, and `useCreateContext`
2 parents 8423858 + e2df79b commit e7cb31f

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

packages/ra-core/src/controller/create/useCreateContext.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { CreateControllerResult } from './useCreateController';
2424
*/
2525
export const useCreateContext = <RecordType extends RaRecord = RaRecord>(
2626
props?: Partial<CreateControllerResult<RecordType>>
27-
): Partial<CreateControllerResult<RecordType>> => {
27+
): CreateControllerResult<RecordType> => {
2828
const context = useContext<CreateControllerResult<RecordType>>(
2929
// Can't find a way to specify the RecordType when CreateContext is declared
3030
// @ts-ignore

packages/ra-core/src/controller/edit/useEditContext.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { EditControllerResult } from './useEditController';
2424
*/
2525
export const useEditContext = <RecordType extends RaRecord = any>(
2626
props?: Partial<EditControllerResult<RecordType>>
27-
): Partial<EditControllerResult<RecordType>> => {
27+
): EditControllerResult<RecordType> => {
2828
// Can't find a way to specify the RecordType when EditContext is declared
2929
// @ts-ignore
3030
const context = useContext<EditControllerResult<RecordType>>(EditContext);

packages/ra-core/src/controller/show/useShowContext.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { ShowControllerResult } from './useShowController';
2424
*/
2525
export const useShowContext = <RecordType extends RaRecord = any>(
2626
props?: Partial<ShowControllerResult<RecordType>>
27-
): Partial<ShowControllerResult<RecordType>> => {
27+
): ShowControllerResult<RecordType> => {
2828
// Can't find a way to specify the RecordType when ShowContext is declared
2929
// @ts-ignore
3030
const context = useContext<ShowControllerResult<RecordType>>(ShowContext);

0 commit comments

Comments
 (0)