Skip to content

Commit

Permalink
Merge pull request #7770 from marmelab/issue7702
Browse files Browse the repository at this point in the history
[Typescript] Fix `FunctionField` generic typing restriction
  • Loading branch information
slax57 authored Jun 2, 2022
2 parents c0d3aa9 + 913d40d commit c3a354a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions packages/ra-ui-materialui/src/field/FunctionField.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { useMemo } from 'react';
import { RaRecord, useRecordContext } from 'ra-core';
import { useRecordContext } from 'ra-core';
import PropTypes from 'prop-types';
import Typography, { TypographyProps } from '@mui/material/Typography';

Expand All @@ -17,7 +17,8 @@ import { PublicFieldProps, InjectedFieldProps, fieldPropTypes } from './types';
* render={record => record && `${record.first_name} ${record.last_name}`}
* />
*/
export const FunctionField = <RecordType extends RaRecord = any>(

export const FunctionField = <RecordType extends unknown = any>(
props: FunctionFieldProps<RecordType>
) => {
const { className, source = '', render, ...rest } = props;
Expand Down Expand Up @@ -45,7 +46,7 @@ FunctionField.propTypes = {
render: PropTypes.func.isRequired,
};

export interface FunctionFieldProps<RecordType extends RaRecord = any>
export interface FunctionFieldProps<RecordType extends unknown = any>
extends PublicFieldProps,
InjectedFieldProps<RecordType>,
Omit<TypographyProps, 'textAlign'> {
Expand Down
3 changes: 1 addition & 2 deletions packages/ra-ui-materialui/src/field/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export interface PublicFieldProps {
fullWidth?: boolean;
}

// Props injected by react-admin
export interface InjectedFieldProps<RecordType extends RaRecord = any> {
export interface InjectedFieldProps<RecordType = any> {
record?: RecordType;
resource?: string;
}
Expand Down

0 comments on commit c3a354a

Please sign in to comment.