Skip to content

Commit 74b216e

Browse files
RobotSailfreben
authored andcommitted
set PropsWithChildren as explicit type on components
Signed-off-by: Oleg S <97077423+RobotSail@users.noreply.github.com>
1 parent 38d8ad9 commit 74b216e

64 files changed

Lines changed: 149 additions & 110 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/weak-rats-serve.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@backstage/core-components': patch
3+
'@backstage/plugin-stack-overflow': patch
4+
'@backstage/plugin-catalog-react': patch
5+
'@backstage/plugin-search-react': patch
6+
'@backstage/plugin-api-docs': patch
7+
'@backstage/plugin-techdocs': patch
8+
'@backstage/plugin-catalog': patch
9+
'@backstage/plugin-search': patch
10+
'@backstage/plugin-fossa': patch
11+
'@backstage/plugin-home': patch
12+
'@backstage/plugin-org': patch
13+
---
14+
15+
Components with empty default props now explicitly declare PropsWithChildren as type

microsite/src/components/contentBlock/contentBlock.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Link from '@docusaurus/Link';
22
import clsx from 'clsx';
3-
import React, { FC, PropsWithChildren, ReactNode } from 'react';
3+
import React, { PropsWithChildren, ReactNode } from 'react';
44

55
import contentBlockStyles from './contentBlock.module.scss';
66

packages/app/src/components/home/templates/DefaultTemplate.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
} from '@backstage/plugin-search-react';
3939
import { stackOverflowApiRef, HomePageStackOverflowQuestions } from '@backstage/plugin-stack-overflow';
4040
import { Grid, makeStyles } from '@material-ui/core';
41-
import React, { ComponentType } from 'react';
41+
import React, { ComponentType, PropsWithChildren } from 'react';
4242

4343
const entities = [
4444
{
@@ -107,7 +107,7 @@ starredEntitiesApi.toggleStarred('component:default/example-starred-entity-4');
107107
export default {
108108
title: 'Plugins/Home/Templates',
109109
decorators: [
110-
(Story: ComponentType<{}>) =>
110+
(Story: ComponentType<PropsWithChildren<{}>>) =>
111111
wrapInTestApp(
112112
<>
113113
<TestApiProvider

packages/core-app-api/api-report.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,14 @@ export class ApiResolver implements ApiHolder {
145145

146146
// @public
147147
export type AppComponents = {
148-
NotFoundErrorPage: ComponentType<{}>;
148+
NotFoundErrorPage: ComponentType<PropsWithChildren<{}>>;
149149
BootErrorPage: ComponentType<BootErrorPageProps>;
150-
Progress: ComponentType<{}>;
150+
Progress: ComponentType<PropsWithChildren<{}>>;
151151
Router: ComponentType<{
152152
basename?: string;
153153
}>;
154154
ErrorBoundaryFallback: ComponentType<ErrorBoundaryFallbackProps>;
155-
ThemeProvider?: ComponentType<{}>;
155+
ThemeProvider?: ComponentType<PropsWithChildren<{}>>;
156156
SignInPage?: ComponentType<SignInPageProps>;
157157
};
158158

@@ -274,9 +274,9 @@ export type AuthApiCreateOptions = {
274274
export type BackstageApp = {
275275
getPlugins(): BackstagePlugin[];
276276
getSystemIcon(key: string): IconComponent | undefined;
277-
createRoot(element: JSX.Element): ComponentType<{}>;
278-
getProvider(): ComponentType<{}>;
279-
getRouter(): ComponentType<{}>;
277+
createRoot(element: JSX.Element): ComponentType<PropsWithChildren<{}>>;
278+
getProvider(): ComponentType<PropsWithChildren<{}>>;
279+
getRouter(): ComponentType<PropsWithChildren<{}>>;
280280
};
281281

282282
// @public

packages/core-app-api/src/app/AppManager.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export class AppManager implements BackstageApp {
242242
return this.components;
243243
}
244244

245-
createRoot(element: JSX.Element): ComponentType<{}> {
245+
createRoot(element: JSX.Element): ComponentType<PropsWithChildren<{}>> {
246246
const AppProvider = this.getProvider();
247247
const AppRoot = () => {
248248
return <AppProvider>{element}</AppProvider>;
@@ -251,7 +251,7 @@ export class AppManager implements BackstageApp {
251251
}
252252

253253
#getProviderCalled = false;
254-
getProvider(): ComponentType<{}> {
254+
getProvider(): ComponentType<PropsWithChildren<{}>> {
255255
if (this.#getProviderCalled) {
256256
throw new Error(
257257
'app.getProvider() or app.createRoot() has already been called, and can only be called once',
@@ -404,7 +404,7 @@ export class AppManager implements BackstageApp {
404404
return Provider;
405405
}
406406

407-
getRouter(): ComponentType<{}> {
407+
getRouter(): ComponentType<PropsWithChildren<{}>> {
408408
return AppRouter;
409409
}
410410

packages/core-app-api/src/app/types.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { ComponentType } from 'react';
17+
import { ComponentType, PropsWithChildren } from 'react';
1818
import {
1919
AnyApiFactory,
2020
AppTheme,
@@ -67,12 +67,12 @@ export type ErrorBoundaryFallbackProps = {
6767
* @public
6868
*/
6969
export type AppComponents = {
70-
NotFoundErrorPage: ComponentType<{}>;
70+
NotFoundErrorPage: ComponentType<PropsWithChildren<{}>>;
7171
BootErrorPage: ComponentType<BootErrorPageProps>;
72-
Progress: ComponentType<{}>;
72+
Progress: ComponentType<PropsWithChildren<{}>>;
7373
Router: ComponentType<{ basename?: string }>;
7474
ErrorBoundaryFallback: ComponentType<ErrorBoundaryFallbackProps>;
75-
ThemeProvider?: ComponentType<{}>;
75+
ThemeProvider?: ComponentType<PropsWithChildren<{}>>;
7676

7777
/**
7878
* An optional sign-in page that will be rendered instead of the AppRouter at startup.
@@ -319,23 +319,23 @@ export type BackstageApp = {
319319
* );
320320
* ```
321321
*/
322-
createRoot(element: JSX.Element): ComponentType<{}>;
322+
createRoot(element: JSX.Element): ComponentType<PropsWithChildren<{}>>;
323323

324324
/**
325325
* Provider component that should wrap the Router created with getRouter()
326326
* and any other components that need to be within the app context.
327327
*
328328
* @deprecated Use {@link BackstageApp.createRoot} instead.
329329
*/
330-
getProvider(): ComponentType<{}>;
330+
getProvider(): ComponentType<PropsWithChildren<{}>>;
331331

332332
/**
333333
* Router component that should wrap the App Routes create with getRoutes()
334334
* and any other components that should only be available while signed in.
335335
*
336336
* @deprecated Import and use the {@link AppRouter} component from `@backstage/core-app-api` instead
337337
*/
338-
getRouter(): ComponentType<{}>;
338+
getRouter(): ComponentType<PropsWithChildren<{}>>;
339339
};
340340

341341
/**

packages/core-components/src/components/Link/Link.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import React, { ComponentType } from 'react';
16+
import React, { ComponentType, PropsWithChildren } from 'react';
1717
import { Link } from './Link';
1818
import {
1919
Route,
@@ -37,7 +37,7 @@ export default {
3737
title: 'Navigation/Link',
3838
component: Link,
3939
decorators: [
40-
(Story: ComponentType<{}>) =>
40+
(Story: ComponentType<PropsWithChildren<{}>>) =>
4141
wrapInTestApp(
4242
<div>
4343
<div>

packages/core-components/src/components/LinkButton/LinkButton.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import React, { ComponentType } from 'react';
16+
import React, { ComponentType, PropsWithChildren } from 'react';
1717
import { LinkButton } from './LinkButton';
1818
import { useLocation } from 'react-router-dom';
1919
import { createRouteRef, useRouteRef } from '@backstage/core-plugin-api';
@@ -39,7 +39,7 @@ export default {
3939
title: 'Inputs/Button',
4040
component: LinkButton,
4141
decorators: [
42-
(Story: ComponentType<{}>) =>
42+
(Story: ComponentType<PropsWithChildren<{}>>) =>
4343
wrapInTestApp(
4444
<>
4545
<Typography>

packages/core-components/src/components/LogViewer/LogViewer.stories.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414
* limitations under the License.
1515
*/
1616

17-
import React, { ComponentType } from 'react';
17+
import React, { ComponentType, PropsWithChildren } from 'react';
1818
import { wrapInTestApp } from '@backstage/test-utils';
1919
import { LogViewer } from './LogViewer';
2020

2121
export default {
2222
title: 'Data Display/LogViewer',
2323
component: LogViewer,
24-
decorators: [(Story: ComponentType<{}>) => wrapInTestApp(<Story />)],
24+
decorators: [
25+
(Story: ComponentType<PropsWithChildren<{}>>) => wrapInTestApp(<Story />),
26+
],
2527
};
2628

2729
const exampleLog = `Starting up task with 3 steps

packages/core-components/src/layout/Sidebar/Sidebar.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import MenuBookIcon from '@material-ui/icons/MenuBook';
2323
import CloudQueueIcon from '@material-ui/icons/CloudQueue';
2424
import AcUnitIcon from '@material-ui/icons/AcUnit';
2525
import AppsIcon from '@material-ui/icons/Apps';
26-
import React, { ComponentType } from 'react';
26+
import React, { ComponentType, PropsWithChildren } from 'react';
2727
import { SidebarPage } from './Page';
2828
import { Sidebar } from './Bar';
2929
import { SidebarGroup } from './SidebarGroup';
@@ -46,7 +46,7 @@ export default {
4646
title: 'Layout/Sidebar',
4747
component: Sidebar,
4848
decorators: [
49-
(Story: ComponentType<{}>) =>
49+
(Story: ComponentType<PropsWithChildren<{}>>) =>
5050
wrapInTestApp(<Story />, { mountedRoutes: { '/': routeRef } }),
5151
],
5252
};

0 commit comments

Comments
 (0)