Skip to content

Commit 9056567

Browse files
Convert everything to Typescript (#137)
2 parents ba16e20 + 9f484df commit 9056567

31 files changed

+281
-113
lines changed

package-lock.json

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
6060
"@eslint/js": "^9.17.0",
6161
"@svgr/webpack": "^6.2.1",
62+
"@types/react-dom": "^19.1.3",
6263
"daisyui": "^5.0.28",
6364
"eslint-config-react-app": "^7.0.1",
6465
"eslint-define-config": "^2.1.0",

src/declarations.d.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Declarations file for fixing certain type errors
2+
3+
declare module "*.webp" {
4+
const value: string;
5+
export default value;
6+
}
7+
8+
declare type PagesState = {
9+
pages: string[];
10+
activePage: string;
11+
}
12+
13+
// FOr about section idk what this is tbh
14+
declare interface AboutItem {
15+
title: string;
16+
description: string;
17+
}
18+
19+
// This the result returned from 'packageOpportunityCard' in opportunity_routes.py in backend
20+
declare interface OpportunityCardData {
21+
"id": string,
22+
"title": string,
23+
"professor": string,
24+
"season": stringr,
25+
"location": string,
26+
"year": string,
27+
}
28+
29+
// This the result returned from 'packageIndividualOpportunity' in opportunity_routes.py in backend
30+
declare interface OpportunityData {
31+
"id": string;
32+
"name": string;
33+
"description": string;
34+
"recommended_experience": string;
35+
"author": string;
36+
"authorProfile": string;
37+
"department": string;
38+
"pay": string;
39+
"credits"?: string;
40+
"semester": string
41+
"application_due": string;
42+
"recommended_class_years": string;
43+
}

src/opportunities/components/AboutSection.js renamed to src/opportunities/components/AboutSection.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import React from "react";
22
import AboutSectionElement from "./AboutSectionElement";
33

4-
const AboutSection = ({ aboutSection }) => {
4+
interface AboutSectionProps {
5+
aboutSection: AboutItem[];
6+
}
7+
8+
const AboutSection = ({ aboutSection }: AboutSectionProps) => {
59
let i = 0;
610

711
return (

src/opportunities/components/AboutSectionElement.js renamed to src/opportunities/components/AboutSectionElement.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22

3-
const AboutSectionElement = ({ title, description }) => {
3+
const AboutSectionElement = ({ title, description }: { title: string, description: string }) => {
44
return (
55
<div className="about-head">
66
<h5 className="about-title">{title}</h5>

src/opportunities/components/HorizontalIconButton.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
import React from "react";
2-
import PropTypes from "prop-types";
32

4-
const HorizontalIconButton = ({ children, onClick, icon, special }) => {
3+
interface HorizontalIconButtonProps {
4+
children?: React.ReactNode;
5+
onClick: (arg?: React.ReactNode) => void;
6+
icon: React.ReactNode;
7+
special: boolean;
8+
}
9+
10+
const HorizontalIconButton = ({ children, onClick, icon, special }: HorizontalIconButtonProps) => {
511
return (
612
<div
713
className={`${special && "font-medium"} ${
@@ -21,11 +27,4 @@ const HorizontalIconButton = ({ children, onClick, icon, special }) => {
2127
);
2228
};
2329

24-
HorizontalIconButton.propTypes = {
25-
children: PropTypes.node,
26-
onClick: PropTypes.func.isRequired,
27-
icon: PropTypes.node,
28-
special: PropTypes.bool,
29-
}
30-
3130
export default HorizontalIconButton;

src/opportunities/components/JobDescription.js renamed to src/opportunities/components/JobDescription.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from "react";
22

3-
const JobDescription = ({ title, description }) => {
3+
const JobDescription = ({ title, description }: { title?: string, description: string }) => {
44
return (
55
<article className="job-desc-header">
66
<div className="job-desc-title">{title || "Role Description"}</div>

src/opportunities/components/JobDetails.js renamed to src/opportunities/components/JobDetails.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ import AboutSection from "./AboutSection";
33
import JobHeader from "./JobHeader";
44
import JobDescription from "./JobDescription";
55

6+
interface JobDetailsProps {
7+
name: string;
8+
author: string;
9+
department: string;
10+
description: string;
11+
authorProfile: string;
12+
aboutSection: AboutItem[];
13+
recommended_experience: string;
14+
}
15+
616
const JobDetails = ({
717
name,
818
author,
@@ -11,7 +21,7 @@ const JobDetails = ({
1121
authorProfile,
1222
aboutSection,
1323
recommended_experience,
14-
}) => {
24+
}: JobDetailsProps) => {
1525
return (
1626
<article className="job-details-header">
1727
<JobHeader

src/opportunities/components/JobHeader.js renamed to src/opportunities/components/JobHeader.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import React from "react";
22
import Avatar from "../../shared/components/UIElements/Avatar.tsx";
33

4-
const JobHeader = ({ title, img, author, department }) => {
4+
interface JobHeaderProps {
5+
title: string;
6+
img: string;
7+
author: string;
8+
department: string;
9+
}
10+
11+
const JobHeader = ({ title, img, author, department }: JobHeaderProps) => {
512
return (
613
<section className="job-header-header">
714
<h2 className="job-header-title">{title}</h2>

src/opportunities/components/JobInteractionButton.js renamed to src/opportunities/components/JobInteractionButton.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import React from "react";
22

3-
const JobInteractionButton = ({ className, special, onClick, children }) => {
3+
interface JobInteractionButtonProps {
4+
className: string;
5+
special: string;
6+
onClick: () => void
7+
children: React.ReactNode
8+
}
9+
10+
const JobInteractionButton = ({ className, special, onClick, children }: JobInteractionButtonProps) => {
411
return (
512
<div className={`${className}`}>
613
<button

0 commit comments

Comments
 (0)