Skip to content

Commit ad31f80

Browse files
authored
Add TypeScript type annotations for improved type safety (facebook#4511)
1 parent 6981e1d commit ad31f80

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

website/docusaurus.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export type EditUrlButton = {
2929
href: string;
3030
};
3131

32-
const commonDocsOptions = {
32+
const commonDocsOptions: PluginContentDocs.Options = {
3333
breadcrumbs: false,
3434
showLastUpdateAuthor: false,
3535
showLastUpdateTime: true,

website/src/components/Home/Platforms/FoxFact.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import React from 'react';
99

10-
function FoxFact({className}) {
10+
function FoxFact({className}: {className: string}) {
1111
return (
1212
<svg
1313
width={167}

website/src/components/Home/Section/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import React from 'react';
99

1010
import styles from './styles.module.css';
1111

12-
function Section({children}) {
12+
function Section({children}: React.PropsWithChildren) {
1313
return (
1414
<div className={styles.wrapper}>
1515
<div className={styles.container}>{children}</div>

website/src/pages/showcase.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import type users from '../../showcase.json';
1313
import IconExternalLink from '../theme/Icon/ExternalLink';
1414
import ThemedImage from '@theme/ThemedImage';
1515

16-
const renderApp = (app, i) => <AppBox app={app} key={`app-${app.name}-${i}`} />;
16+
type UserAppType = (typeof users)[keyof typeof users][number];
17+
18+
const renderApp = (app: UserAppType, i: number) => (
19+
<AppBox app={app} key={`app-${app.name}-${i}`} />
20+
);
1721

1822
function Section({
1923
children,
@@ -22,7 +26,7 @@ function Section({
2226
return <section className={`Section ${background}`}>{children}</section>;
2327
}
2428

25-
const AppBox = ({app}) => {
29+
const AppBox = ({app}: {app: UserAppType}) => {
2630
const imgSource = useBaseUrl(
2731
app.icon.startsWith('http') ? app.icon : 'img/showcase/' + app.icon
2832
);
@@ -38,7 +42,7 @@ const AppBox = ({app}) => {
3842
<h3>{app.name}</h3>
3943
{renderLinks(app)}
4044
</div>
41-
{app.infoLink && (
45+
{'infoTitle' in app && app.infoLink && (
4246
<a
4347
className="articleButton"
4448
href={app.infoLink}
@@ -53,7 +57,7 @@ const AppBox = ({app}) => {
5357
);
5458
};
5559

56-
const renderLinks = app => {
60+
const renderLinks = (app: UserAppType) => {
5761
const links = [
5862
app.linkAppStore ? (
5963
<a key="ios" href={app.linkAppStore} target="_blank">
@@ -65,12 +69,12 @@ const renderLinks = app => {
6569
Android
6670
</a>
6771
) : null,
68-
app.linkDesktop ? (
72+
'linkDesktop' in app && app.linkDesktop ? (
6973
<a key="desktop" href={app.linkDesktop} target="_blank">
7074
Desktop
7175
</a>
7276
) : null,
73-
app.linkMetaQuest ? (
77+
'linkMetaQuest' in app && app.linkMetaQuest ? (
7478
<a key="quest" href={app.linkMetaQuest} target="_blank">
7579
Meta&nbsp;Quest
7680
</a>

0 commit comments

Comments
 (0)