Repository navigation
Refactor calendar.js.jsx into TypeScript components - #1831
Purplegaze wants to merge 5 commits into
Conversation
Coverage Report for CI Build 43508803579Coverage increased (+0.01%) to 61.57%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
david-yz-liu
left a comment
There was a problem hiding this comment.
Nice work, @Purplegaze. I just left a few inline comments
| @@ -0,0 +1,154 @@ | |||
| import { LectureTimeframe } from "../common/types" | |||
There was a problem hiding this comment.
throughout, use type-only imports for identifiers that are only imported for type annotations
| let rawLectures = lectureSections.map((lectureSection, _index, selectedLectures) => | ||
| createNewLectures(lectureSection, selectedLectures) | ||
| ); | ||
| let lectures = ([] as LectureTimeframe[]).concat.apply([], rawLectures); |
There was a problem hiding this comment.
I'm wondering whether there's any type inference possible here; rather than using as, can you annotate let lecture: LectureTimeframe[] = ... instead?
| }); | ||
|
|
||
| // Organize the structure of the <fallSession> and <springSession> 2-D dictionaries | ||
| let fallSession: TimetableMap, springSession: TimetableMap;[fallSession, springSession] = initializeSessions(lectures); |
There was a problem hiding this comment.
The original code here was a bit awkward. If initializeSessions has a return type annotation I don't think you need to annotate the variables, and instead just do
let [fallSession, springSession] = initializeSessions(lectures);| * @param timetableMap the map of intervals to active lectures | ||
| */ | ||
| const storeWidths = (timetableMap: TimetableMap): Record<number, number[]> => { | ||
| const widths = {} as Record<number, number[]> |
There was a problem hiding this comment.
Instead of using as, I think you can move the type annotation to the variable directly:
let widths: Record<...> = ...
Proposed Changes
Refactors
js/components/grid/calendar.js.jsxinto separate TypeScript components. Analogue to #1830.Minor changes:
widthattribute of a LectureTimeframe mandatory, as I believe it's always defined. This is to avoid type checking issues where null values are not expected.@PeanutPiglet Since we did these analogous tasks individually, I anticipate we will now need to work together to amalgamate our types and make sure they don't conflict with each other.
...
Screenshots of your changes (if applicable)
Type of Change
(Write an
Xor a brief description next to the type or types that best describe your changes.)Checklist
(Complete each of the following items for your pull request. Indicate that you have completed an item by changing the
[ ]into a[x]in the raw text, or by clicking on the checkbox in the rendered description on GitHub.)Before opening your pull request:
After opening your pull request:
Questions and Comments
Now that Y-courses are in the database, I've noticed they get populated into the timetable grid twice, conflicting with themselves. I'd be happy to fix that in a separate PR after this is done.