Skip to content

Commit 66c04ae

Browse files
committed
client/modules/About/pages/About: add types
1 parent 9a63407 commit 66c04ae

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

client/modules/About/pages/About.tsx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Helmet } from 'react-helmet';
55
import { useTranslation } from 'react-i18next';
66
import { Link } from 'react-router-dom';
77

8+
import type { TFunction } from 'react-i18next';
89
import {
910
AboutPageContent,
1011
Intro,
@@ -27,8 +28,16 @@ import packageData from '../../../../package.json';
2728
import HeartIcon from '../../../images/heart.svg';
2829
import AsteriskIcon from '../../../images/p5-asterisk.svg';
2930
import LogoIcon from '../../../images/p5js-square-logo.svg';
31+
import type { AboutSectionInfoSection } from '../statics/aboutData';
32+
import { RootState } from '../../../reducers';
3033

31-
const AboutSection = ({ section, t }) => (
34+
const AboutSection = ({
35+
section,
36+
t
37+
}: {
38+
section: AboutSectionInfoSection;
39+
t: TFunction<'translation'>;
40+
}) => (
3241
<Section>
3342
<h2>{t(section.header)}</h2>
3443
<SectionContainer>
@@ -47,11 +56,15 @@ const AboutSection = ({ section, t }) => (
4756
</Section>
4857
);
4958

50-
const About = () => {
59+
export const About = () => {
5160
const { t } = useTranslation();
5261

53-
const p5version = useSelector((state) => {
54-
const index = state.files.find((file) => file.name === 'index.html');
62+
const p5version = useSelector((state: RootState) => {
63+
const index = state.files.find(
64+
(file: {
65+
name: string /** TODO: update once files types are defined in server */;
66+
}) => file.name === 'index.html'
67+
);
5568
return index?.content.match(/\/p5@([\d.]+)\//)?.[1];
5669
});
5770

@@ -91,7 +104,11 @@ const About = () => {
91104
</Intro>
92105

93106
{AboutSectionInfo.map((section) => (
94-
<AboutSection key={t(section.header)} section={section} t={t} />
107+
<AboutSection
108+
key={t(section.header) as string}
109+
section={section}
110+
t={t}
111+
/>
95112
))}
96113

97114
<Contact>
@@ -166,5 +183,3 @@ AboutSection.propTypes = {
166183
}).isRequired,
167184
t: PropTypes.func.isRequired
168185
};
169-
170-
export default About;

client/modules/About/statics/aboutData.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ export interface AboutSectionInfoItem {
3131
title: string;
3232
description: string;
3333
}
34-
export interface AboutSectionInfoSections {
34+
export interface AboutSectionInfoSection {
3535
header: string;
3636
items: AboutSectionInfoItem[];
3737
}
38-
export const AboutSectionInfo = [
38+
export const AboutSectionInfo: AboutSectionInfoSection[] = [
3939
{
4040
header: 'About.NewP5',
4141
items: [

client/routes.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Route as RouterRoute, Switch } from 'react-router-dom';
66
import App from './modules/App/App';
77
import IDEView from './modules/IDE/pages/IDEView';
88
import FullView from './modules/IDE/pages/FullView';
9-
import About from './modules/About/pages/About';
9+
import { About } from './modules/About/pages/About';
1010
import CodeOfConduct from './modules/Legal/pages/CodeOfConduct';
1111
import PrivacyPolicy from './modules/Legal/pages/PrivacyPolicy';
1212
import TermsOfUse from './modules/Legal/pages/TermsOfUse';

0 commit comments

Comments
 (0)