Right now, NUSMods just checks on load for whether a timetable object exists. This could potentially cause issues since we never explicitly check that data is of type PageData. Notice here that data is implicitly converted from any as returned in JSON.parse to PageData, received as a parameter to validatePageData.
Right now, NUSMods just checks on load for whether a timetable object exists. This could potentially cause issues since we never explicitly check that
data
is of typePageData
. Notice here thatdata
is implicitly converted fromany
as returned inJSON.parse
toPageData
, received as a parameter tovalidatePageData
.https://github.com/nusmodifications/nusmods/blob/47238fa8203fb0b6432b74a9d737e7fc4314b4ae/export/src/data.ts#L49-L50
https://github.com/nusmodifications/nusmods/blob/089993f56557c729572284b762384424f7806d53/export/src/data.ts#L66-L71
We could implement a basic check that the data it contains is well-formed according to
PageData
's type definition.