Repository navigation
Migration to typescript - #101
kamranayesh wants to merge 15 commits into
Conversation
…d some data to typescript
papsavas
left a comment
There was a problem hiding this comment.
Thanks for this, it will REALLY help us moving forward. Couple of notes
| const locations: Location[] = [ | ||
| { | ||
| floor: i18n.t("mezzanine_floor"), | ||
| floor: String(i18n.t("mezzanine_floor")), |
There was a problem hiding this comment.
Same thing as as string. If the result is null, we would be assigning 'null' as String(null) -> 'null'
Resolve it with i18n.t(....) ?? undefined
| //this is needed to make sure it rerenders when the office selected in the floor changes | ||
| key={marked_position_x + " " + marked_position_y} | ||
| src={showGroundFloorImg ? GROUND_FLOOR_IMG_URL : imageURL} | ||
| src={showGroundFloorImg ? GROUND_FLOOR_IMG_URL : imageURL||""} |
| {showGroundFloorImg ? ( | ||
| <Text pt={"0.125rem"} px="1rem"> | ||
| {i18n.t("enter_elevator_prompt")} {floor.toLowerCase()}{" "} | ||
| {i18n.t("enter_elevator_prompt")} {floor&&floor.toLowerCase()}{" "} |
There was a problem hiding this comment.
you can just floor?.toLowerCase() otherwise this might print false
| key={index} | ||
| value={option.title} | ||
| onClick={() => handleMenuItemClick(option.title)} | ||
| onClick={() => handleMenuItemClick(option.title||"")} |
There was a problem hiding this comment.
since useMapData handles empty strings we're ok always calling the handler, but it would be wiser to use option.title ?? undefined if for some reason this becomes nullable
| <VStack> | ||
| {/* <input type="text" onChange={onTextChangeHandler} /> */} | ||
| <SecrCard data={secretary} key={secretary.tel} /> | ||
| {secretary&&<SecrCard data={secretary} key={secretary?.tel||""} />} |
There was a problem hiding this comment.
Avoid this conditional rendering method.
Use
{secretary ? <SecrCard
key={secretary.tel} //this is defined, no need for optional chaining (?.)
data={secretary}
/> : null}| fontFamily="Syne" | ||
| type="text" | ||
| placeholder={i18n.t("searchProf")} | ||
| placeholder={i18n.t("searchProf")||""} |
| > | ||
| <UnorderedList spacing={2}> | ||
| {Object.values(foodMenu[key]).map((dish, index) => ( | ||
| {Object.values(foodMenu[key as FoodMenuKey]).map((dish, index) => ( |
There was a problem hiding this comment.
not really important but you could raise typing to the outer (Object.keys(foodMenu) as Array<keyof FoodMenu>).map(...) having no need to cast later
|
Can you add further documentation regarding its deployment in docs/deployment.md? Is it still just npm run build and the rest still the same? Also should typescript's version be explicitly declared?(My JS ecosystem knowledge is limited) @papsavas can you provide your opinion in on this? |
|
Thank you @papsavas, the README will soon have a section for the setup of the developer environment, @kamranayesh along with the other suggested changes make sure to include the documentation for the deployment as mentioned above and we will soon review to merge it and deploy it. |
|
Thank you @papsavas for your comments i will resolve them all. I will surely add documentation and update readme as well. |
|
@GeorgeFkd I have updated pr with resolved comments and added deployment instructions in readme. |
|
@kamranayesh resolve the merge conflicts |
and |
|
@kamranayesh How is it working locally? |
|
@shivam-sharma7 Its working fine. I request other contributors to checkout and test it too. |
shivarm
left a comment
There was a problem hiding this comment.
I am seeing some error while reviewing this
- Setting page layout is looking weird
- when i have clicked
http://localhost:3000/firstyearinfothe freshmen card then its show me the following errors
@GeorgeFkd @GeorgeApos @Tsalmas-Anastasios What do you think?
|
It seems to have to do with the markdown files being used there. The freshmen articles are just markdown files rendered into react components using a library. The imports there i remember were a bit weird. If you cant resolve it i will investigate it in a few days. |
|
Are we planning to integrate vite here or in a future PR?
vite react-ts template should be handy for this |
|
@papsavas First of all we have to deal with markdown files then it would be next step because I am getting same error while migrating in |
|
@papsavas I think we could do it on a next PR bcs this one is a huge chamge itself already. Also as @shivam-sharma7 mentioned we should investigate how to make markdown work in Vite. |
papsavas
left a comment
There was a problem hiding this comment.
the "implicit inference" review is not crucial right now. I would prioritize the missed as string one to speed up the merging process. Its a long PR already, we don't need to make it longer
| let departmentLocations = { | ||
| import { Location } from "../../../../../hooks/useMapData"; | ||
| import { DepartmentLocations } from ".."; | ||
| const locations: Location[] = [...second_floor,...third_floor, ...fourth_floor]; |
There was a problem hiding this comment.
you do not need to explicitly type this, its already infered as Location[] since all floors are. In general, prefer implicit inference. Code flows better that way
|
As there are some legacy peer dependencies it needs This will be temporarily allowed in order to push through this PR. |
i updated package.json please try again |
|
Hi @GeorgeFkd @GeorgeApos @papsavas I am interested in migration of this codebase to TS ... is this PR complete the migration or should i open mine for the migration of the codebase |





Overview
This pull request introduces comprehensive TypeScript (TS) support by migrating the existing JavaScript (JS) codebase to TypeScript and transforming JSX files to TSX. This initiative enhances code quality, provides static typing, and improves maintainability and scalability of the project.
Changes Made
TypeScript Migration:
JSX to TSX Conversion:
Configuration Updates:
Next Steps
Testing and Validation:
Continuous Improvement:
This migration from JavaScript to TypeScript and JSX to TSX represents a significant milestone in enhancing the project's robustness, maintainability, and developer experience. The transition leverages TypeScript's advanced features to elevate the project's code quality and position it for sustainable growth and community engagement.
#gsoc_participant
Kamran Ayesh