Skip to content

Commit f95d808

Browse files
authored
Merge pull request #5298 from marmelab/fix-types
More TS fixes
2 parents 19deccf + 54f0ed0 commit f95d808

33 files changed

+234
-85
lines changed

examples/demo/package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77
"@material-ui/icons": "^4.9.1",
88
"@types/inflection": "^1.5.28",
99
"@types/recharts": "^1.8.10",
10-
"data-generator-retail": "^3.0.0",
10+
"data-generator-retail": "^3.9.0-beta.1",
1111
"fakerest": "~2.1.0",
1212
"fetch-mock": "~6.3.0",
1313
"json-graphql-server": "~2.1.3",
1414
"proxy-polyfill": "^0.3.0",
15-
"ra-data-fakerest": "^3.0.0",
16-
"ra-data-graphql-simple": "^3.0.0",
17-
"ra-data-simple-rest": "^3.0.0",
18-
"ra-i18n-polyglot": "^3.0.0",
19-
"ra-input-rich-text": "^3.0.0",
20-
"ra-language-english": "^3.0.0",
21-
"ra-language-french": "^3.0.0",
15+
"ra-data-fakerest": "^3.9.0-beta.1",
16+
"ra-data-graphql-simple": "^3.9.0-beta.1",
17+
"ra-data-simple-rest": "^3.9.0-beta.1",
18+
"ra-i18n-polyglot": "^3.9.0-beta.1",
19+
"ra-input-rich-text": "^3.9.0-beta.1",
20+
"ra-language-english": "^3.9.0-beta.1",
21+
"ra-language-french": "^3.9.0-beta.1",
2222
"react": "^16.9.0",
23-
"react-admin": "^3.0.0",
23+
"react-admin": "^3.9.0-beta.1",
2424
"react-app-polyfill": "^1.0.4",
2525
"react-dom": "^16.9.0",
2626
"react-redux": "^7.1.0",
@@ -54,4 +54,4 @@
5454
"source-map-explorer": "^2.0.0",
5555
"typescript": "^4.0.2"
5656
}
57-
}
57+
}

examples/simple/package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737
"@babel/polyfill": "^7.10.4",
3838
"@material-ui/core": "^4.10.0",
3939
"@material-ui/icons": "^4.9.1",
40-
"ra-data-fakerest": "^3.0.0",
41-
"ra-i18n-polyglot": "^3.0.0",
42-
"ra-input-rich-text": "^3.0.0",
43-
"ra-language-english": "^3.0.0",
44-
"ra-language-french": "^3.0.0",
40+
"ra-data-fakerest": "^3.9.0-beta.1",
41+
"ra-i18n-polyglot": "^3.9.0-beta.1",
42+
"ra-input-rich-text": "^3.9.0-beta.1",
43+
"ra-language-english": "^3.9.0-beta.1",
44+
"ra-language-french": "^3.9.0-beta.1",
4545
"react": "^16.9.0",
46-
"react-admin": "^3.0.0",
46+
"react-admin": "^3.9.0-beta.1",
4747
"react-dom": "^16.9.0"
4848
}
4949
}

examples/tutorial/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
"private": true,
55
"dependencies": {
66
"@material-ui/core": "^4.10.0",
7-
"ra-data-json-server": "^3.0.0",
7+
"ra-data-json-server": "^3.9.0-beta.1",
88
"react": "^16.9.0",
9-
"react-admin": "^3.0.0",
9+
"react-admin": "^3.9.0-beta.1",
1010
"react-dom": "^16.9.0",
1111
"react-scripts": "^3.0.0"
1212
},
@@ -21,4 +21,4 @@
2121
"not ie <= 11",
2222
"not op_mini all"
2323
]
24-
}
24+
}

packages/ra-core/src/controller/input/useReferenceArrayInputController.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,15 @@ interface ReferenceArrayInputProps {
216216
}
217217

218218
interface Option {
219-
basePath: string;
219+
basePath?: string;
220220
filter?: any;
221221
filterToQuery?: (filter: any) => any;
222222
input: FieldInputProps<any, HTMLElement>;
223223
options?: any;
224224
perPage?: number;
225225
record?: Record;
226226
reference: string;
227-
resource: string;
227+
resource?: string;
228228
sort?: SortPayload;
229229
source: string;
230230
}

packages/ra-core/src/controller/useShowController.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface ShowProps {
1515
hasShow?: boolean;
1616
hasList?: boolean;
1717
id: Identifier;
18-
resource: string;
18+
resource?: string;
1919
[key: string]: any;
2020
}
2121

packages/ra-core/src/dataProvider/index.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import Query from './Query';
77
import cacheDataProviderProxy from './cacheDataProviderProxy';
88
import undoableEventEmitter from './undoableEventEmitter';
99
import useDataProvider from './useDataProvider';
10-
import useMutation from './useMutation';
11-
import useQuery from './useQuery';
12-
import useQueryWithStore from './useQueryWithStore';
10+
import useMutation, { UseMutationValue } from './useMutation';
11+
import useQuery, { UseQueryValue } from './useQuery';
12+
import useQueryWithStore, { QueryOptions } from './useQueryWithStore';
1313
import withDataProvider from './withDataProvider';
14-
import useGetOne from './useGetOne';
14+
import useGetOne, { UseGetOneHookValue } from './useGetOne';
1515
import useGetList from './useGetList';
1616
import useGetMany from './useGetMany';
1717
import useGetManyReference from './useGetManyReference';
@@ -24,6 +24,13 @@ import useDeleteMany from './useDeleteMany';
2424
import useRefreshWhenVisible from './useRefreshWhenVisible';
2525
import useIsAutomaticRefreshEnabled from './useIsAutomaticRefreshEnabled';
2626

27+
export type {
28+
QueryOptions,
29+
UseMutationValue,
30+
UseQueryValue,
31+
UseGetOneHookValue,
32+
};
33+
2734
export {
2835
cacheDataProviderProxy,
2936
convertLegacyDataProvider,

packages/ra-core/src/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -387,12 +387,14 @@ export type LoginComponent = ComponentType<LoginComponentProps>;
387387
export type DashboardComponent = ComponentType<WithPermissionsChildrenParams>;
388388

389389
export interface LayoutProps {
390+
appBar?: ComponentType;
390391
dashboard?: DashboardComponent;
391392
logout?: ReactNode;
392393
menu?: ComponentType<{
393394
logout?: ReactNode;
394395
hasDashboard?: boolean;
395396
}>;
397+
sideBar?: ComponentType;
396398
theme?: ThemeOptions;
397399
title?: TitleComponent;
398400
}

packages/ra-data-fakerest/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@
4444
"rimraf": "^2.6.3"
4545
},
4646
"peerDependencies": {
47-
"ra-core": "^3.0.0"
47+
"ra-core": "^3.9.0-beta.1"
4848
}
4949
}

packages/ra-data-graphql-simple/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"peerDependencies": {
4242
"graphql": "^14.1.1",
43-
"ra-core": "^3.0.0"
43+
"ra-core": "^3.9.0-beta.1"
4444
},
4545
"devDependencies": {
4646
"cross-env": "^5.2.0",

packages/ra-data-graphql/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
},
4141
"peerDependencies": {
4242
"graphql": "^14.1.1",
43-
"ra-core": "^3.0.0"
43+
"ra-core": "^3.9.0-beta.1"
4444
},
4545
"devDependencies": {
4646
"cross-env": "^5.2.0",

packages/ra-data-simple-rest/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@
3232
"rimraf": "^2.6.3"
3333
},
3434
"peerDependencies": {
35-
"ra-core": "^3.0.0"
35+
"ra-core": "^3.9.0-beta.1"
3636
}
3737
}

packages/ra-input-rich-text/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
"watch": "tsc --outDir esm --module es2015 --watch"
4141
},
4242
"peerDependencies": {
43-
"ra-core": "^3.0.0",
44-
"ra-ui-materialui": "^4.3.3",
43+
"ra-core": "^3.9.0-beta.1",
44+
"ra-ui-materialui": "^3.9.0-beta.1",
4545
"react": "^16.9.0",
4646
"react-dom": "^16.9.0"
4747
},

packages/ra-ui-materialui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@material-ui/styles": "^4.3.3",
5757
"final-form": "^4.18.5",
5858
"final-form-arrays": "^3.0.1",
59-
"ra-core": "^3.0.0",
59+
"ra-core": "^3.9.0-beta.1",
6060
"react": "^16.9.0",
6161
"react-dom": "^16.9.0",
6262
"react-final-form": "^6.3.3",

packages/ra-ui-materialui/src/button/Button.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { ButtonProps as MuiButtonProps } from '@material-ui/core/Button';
1313
import { Theme } from '@material-ui/core';
1414
import classnames from 'classnames';
1515
import { Record, RedirectionSideEffect, useTranslate } from 'ra-core';
16+
import { LocationDescriptor } from 'history';
1617

1718
/**
1819
* A generic Button with side icon. Only the icon is displayed on small screens.
@@ -133,7 +134,7 @@ interface Props {
133134
className?: string;
134135
color?: MuiPropTypes.Color;
135136
component?: ReactNode;
136-
to?: string | { pathname: string; search: string };
137+
to?: string | LocationDescriptor;
137138
disabled?: boolean;
138139
label?: string;
139140
size?: 'small' | 'medium' | 'large';

packages/ra-ui-materialui/src/button/DeleteWithConfirmButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ interface Props {
132132
undoable?: boolean;
133133
}
134134

135-
type DeleteWithConfirmButtonProps = Props & ButtonProps;
135+
export type DeleteWithConfirmButtonProps = Props & ButtonProps;
136136

137137
DeleteWithConfirmButton.propTypes = {
138138
basePath: PropTypes.string,

packages/ra-ui-materialui/src/button/index.ts

+15-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@ import BulkDeleteButton from './BulkDeleteButton';
22
import BulkDeleteWithConfirmButton from './BulkDeleteWithConfirmButton';
33
import BulkDeleteWithUndoButton from './BulkDeleteWithUndoButton';
44
import BulkExportButton from './BulkExportButton';
5-
import Button from './Button';
5+
import Button, { ButtonProps } from './Button';
66
import CloneButton from './CloneButton';
77
import CreateButton from './CreateButton';
8-
import DeleteButton from './DeleteButton';
9-
import DeleteWithConfirmButton from './DeleteWithConfirmButton';
10-
import DeleteWithUndoButton from './DeleteWithUndoButton';
8+
import DeleteButton, { DeleteButtonProps } from './DeleteButton';
9+
import DeleteWithConfirmButton, {
10+
DeleteWithConfirmButtonProps,
11+
} from './DeleteWithConfirmButton';
12+
import DeleteWithUndoButton, {
13+
DeleteWithUndoButtonProps,
14+
} from './DeleteWithUndoButton';
1115
import EditButton from './EditButton';
1216
import ExportButton from './ExportButton';
1317
import ListButton from './ListButton';
@@ -17,6 +21,13 @@ import SortButton from './SortButton';
1721
import RefreshButton from './RefreshButton';
1822
import RefreshIconButton from './RefreshIconButton';
1923

24+
export type {
25+
ButtonProps,
26+
DeleteButtonProps,
27+
DeleteWithConfirmButtonProps,
28+
DeleteWithUndoButtonProps,
29+
};
30+
2031
export {
2132
BulkDeleteButton,
2233
BulkDeleteWithConfirmButton,

packages/ra-ui-materialui/src/detail/Show.js packages/ra-ui-materialui/src/detail/Show.tsx

+11-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import PropTypes from 'prop-types';
44
import Card from '@material-ui/core/Card';
55
import { makeStyles } from '@material-ui/core/styles';
66
import classnames from 'classnames';
7-
import { useShowController } from 'ra-core';
7+
import { ShowControllerProps, useShowController } from 'ra-core';
88

99
import DefaultActions from './ShowActions';
1010
import TitleForRecord from '../layout/TitleForRecord';
11+
import { ShowProps } from '../types';
1112

1213
/**
1314
* Page component for the Show view
@@ -52,7 +53,9 @@ import TitleForRecord from '../layout/TitleForRecord';
5253
* );
5354
* export default App;
5455
*/
55-
const Show = props => <ShowView {...props} {...useShowController(props)} />;
56+
const Show = (props: ShowProps) => (
57+
<ShowView {...props} {...useShowController(props)} />
58+
);
5659

5760
Show.propTypes = {
5861
actions: PropTypes.element,
@@ -69,7 +72,11 @@ Show.propTypes = {
6972
title: PropTypes.node,
7073
};
7174

72-
export const ShowView = props => {
75+
interface ShowViewProps
76+
extends ShowProps,
77+
Omit<ShowControllerProps, 'resource'> {}
78+
79+
export const ShowView = (props: ShowViewProps) => {
7380
const {
7481
actions,
7582
aside,
@@ -207,6 +214,6 @@ const sanitizeRestProps = ({
207214
permissions,
208215
translate,
209216
...rest
210-
}) => rest;
217+
}: any) => rest;
211218

212219
export default Show;

packages/ra-ui-materialui/src/detail/ShowActions.js packages/ra-ui-materialui/src/detail/ShowActions.tsx

+18-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
22
import PropTypes from 'prop-types';
3+
import { Record } from 'ra-core';
34

45
import { EditButton } from '../button';
56
import TopToolbar from '../layout/TopToolbar';
@@ -12,7 +13,7 @@ const sanitizeRestProps = ({
1213
hasList,
1314
resource,
1415
...rest
15-
}) => rest;
16+
}: any) => rest;
1617

1718
/**
1819
* Action Toolbar for the Show view
@@ -39,12 +40,27 @@ const sanitizeRestProps = ({
3940
* </Show>
4041
* );
4142
*/
42-
const ShowActions = ({ basePath, className, data, hasEdit, ...rest }) => (
43+
const ShowActions = ({
44+
basePath,
45+
className,
46+
data,
47+
hasEdit,
48+
...rest
49+
}: ShowActionsProps) => (
4350
<TopToolbar className={className} {...sanitizeRestProps(rest)}>
4451
{hasEdit && <EditButton basePath={basePath} record={data} />}
4552
</TopToolbar>
4653
);
4754

55+
export interface ShowActionsProps {
56+
basePath?: string;
57+
className?: string;
58+
data?: Record;
59+
hasEdit?: boolean;
60+
hasList?: boolean;
61+
resource?: string;
62+
}
63+
4864
ShowActions.propTypes = {
4965
basePath: PropTypes.string,
5066
className: PropTypes.string,

0 commit comments

Comments
 (0)