Skip to content

Commit 7aa5559

Browse files
authored
Merge pull request #5313 from marmelab/fix-types
More TS fixes
2 parents da944bf + c0999c1 commit 7aa5559

File tree

8 files changed

+37
-47
lines changed

8 files changed

+37
-47
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { CRUD_CREATE } from '../actions';
2323
import { Record } from '../types';
2424

2525
export interface CreateProps {
26-
basePath: string;
26+
basePath?: string;
2727
hasCreate?: boolean;
2828
hasEdit?: boolean;
2929
hasList?: boolean;
@@ -56,7 +56,7 @@ export interface CreateControllerProps {
5656
setOnFailure: SetOnFailure;
5757
setTransform: SetTransformData;
5858
resource: string;
59-
basePath: string;
59+
basePath?: string;
6060
record?: Partial<Record>;
6161
redirect: RedirectionSideEffect;
6262
version: number;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ import { useTranslate } from '../i18n';
2424
import { CRUD_GET_ONE, CRUD_UPDATE } from '../actions';
2525

2626
export interface EditProps {
27-
basePath: string;
27+
basePath?: string;
2828
hasCreate?: boolean;
2929
hasEdit?: boolean;
3030
hasShow?: boolean;
3131
hasList?: boolean;
32-
id: Identifier;
32+
id?: Identifier;
3333
resource?: string;
3434
undoable?: boolean;
3535
onSuccess?: OnSuccess;
@@ -56,7 +56,7 @@ export interface EditControllerProps<RecordType extends Record = Record> {
5656
setOnFailure: SetOnFailure;
5757
setTransform: SetTransformData;
5858
resource: string;
59-
basePath: string;
59+
basePath?: string;
6060
record?: RecordType;
6161
redirect: RedirectionSideEffect;
6262
version: number;

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { useNotify, useRedirect, useRefresh } from '../sideEffect';
99
import { CRUD_GET_ONE } from '../actions';
1010

1111
export interface ShowProps {
12-
basePath: string;
12+
basePath?: string;
1313
hasCreate?: boolean;
1414
hasedit?: boolean;
1515
hasShow?: boolean;
1616
hasList?: boolean;
17-
id: Identifier;
17+
id?: Identifier;
1818
resource?: string;
1919
[key: string]: any;
2020
}
@@ -24,7 +24,7 @@ export interface ShowControllerProps<RecordType extends Record = Record> {
2424
loaded: boolean;
2525
defaultTitle: string;
2626
resource: string;
27-
basePath: string;
27+
basePath?: string;
2828
record?: RecordType;
2929
version: number;
3030
}

packages/ra-core/src/types.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ export type DashboardComponent = ComponentType<WithPermissionsChildrenParams>;
388388

389389
export interface LayoutProps {
390390
appBar?: ComponentType;
391+
children?: ReactNode;
391392
dashboard?: DashboardComponent;
392393
logout?: ReactNode;
393394
menu?: ComponentType<{
@@ -402,7 +403,7 @@ export interface LayoutProps {
402403
export type LayoutComponent = ComponentType<LayoutProps>;
403404

404405
export interface ResourceComponentInjectedProps {
405-
basePath: string;
406+
basePath?: string;
406407
permissions?: any;
407408
resource?: string;
408409
options?: any;
@@ -416,7 +417,7 @@ export interface ResourceComponentProps<
416417
Params extends { [K in keyof Params]?: string } = {},
417418
C extends StaticContext = StaticContext,
418419
S = LocationState
419-
> extends RouteComponentProps<Params, C, S>,
420+
> extends Partial<RouteComponentProps<Params, C, S>>,
420421
ResourceComponentInjectedProps {}
421422

422423
// deprecated name, use ResourceComponentProps instead
@@ -426,9 +427,9 @@ export interface ResourceComponentPropsWithId<
426427
Params extends { id?: string } = {},
427428
C extends StaticContext = StaticContext,
428429
S = LocationState
429-
> extends RouteComponentProps<Params, C, S>,
430+
> extends Partial<RouteComponentProps<Params, C, S>>,
430431
ResourceComponentInjectedProps {
431-
id: string;
432+
id?: string;
432433
}
433434

434435
// deprecated name, use ResourceComponentPropsWithId instead

packages/ra-ui-materialui/src/detail/Create.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,11 @@ const useStyles = makeStyles(
215215
const sanitizeRestProps = ({
216216
hasCreate = null,
217217
hasEdit = null,
218-
history,
219-
loaded,
220-
loading,
221-
location,
222-
match,
218+
history = null,
219+
loaded = null,
220+
loading = null,
221+
location = null,
222+
match = null,
223223
onFailure = null,
224224
onSuccess = null,
225225
options = null,

packages/ra-ui-materialui/src/detail/Edit.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -237,12 +237,12 @@ const useStyles = makeStyles(
237237
const sanitizeRestProps = ({
238238
hasCreate = null,
239239
hasEdit = null,
240-
history,
241-
id,
242-
loaded,
243-
loading,
244-
location,
245-
match,
240+
history = null,
241+
id = null,
242+
loaded = null,
243+
loading = null,
244+
location = null,
245+
match = null,
246246
onFailure = null,
247247
onSuccess = null,
248248
options = null,

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

+11-23
Original file line numberDiff line numberDiff line change
@@ -191,29 +191,17 @@ const useStyles = makeStyles(
191191
);
192192

193193
const sanitizeRestProps = ({
194-
actions,
195-
aside,
196-
title,
197-
children,
198-
className,
199-
id,
200-
data,
201-
loading,
202-
loaded,
203-
resource,
204-
hasCreate,
205-
hasEdit,
206-
hasList,
207-
hasShow,
208-
version,
209-
match,
210-
location,
211-
history,
212-
options,
213-
locale,
214-
permissions,
215-
translate,
194+
hasCreate = null,
195+
hasEdit = null,
196+
history = null,
197+
id = null,
198+
loaded = null,
199+
loading = null,
200+
location = null,
201+
match = null,
202+
options = null,
203+
permissions = null,
216204
...rest
217-
}: any) => rest;
205+
}) => rest;
218206

219207
export default Show;

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import MenuItemLink, { MenuItemLinkProps } from './MenuItemLink';
1515
import NotFound from './NotFound';
1616
import Notification from './Notification';
1717
import Responsive from './Responsive';
18-
import Sidebar from './Sidebar';
18+
import Sidebar, { SidebarProps } from './Sidebar';
1919
import Title, { TitlePropType } from './Title';
2020
import TitleForRecord from './TitleForRecord';
2121
import TopToolbar from './TopToolbar';
@@ -42,6 +42,7 @@ export {
4242
Notification,
4343
Responsive,
4444
Sidebar,
45+
SidebarProps,
4546
Title,
4647
TitleForRecord,
4748
TitlePropType,

0 commit comments

Comments
 (0)