Oppia uses Angular as the frontend framework with TypeScript as the primary language, hence this codebase is fully typed. These type checks are enforced during compile time with exceptions and errors more likely to occur during compilation. This explicit typing makes code self-documenting, produces less bugs, enhances understanding of the code and reduces wastage of time from debugging errors at runtime.
strict is a typescript compiler option which turns on the following set of rules (strict mode):
- noImplicitAny
- noImplicitThis
- strictNullChecks
- strictPropertyInitialization
- strictBindCallApply
- strictFunctionTypes
Enabling the above rules helps to reduce the chances of getting unpredictable results and makes the code more robust but currently, Oppia’s code base does not pass these strict rules. This makes the code prone to unexpected actions and errors.
The project aimed to enable TypeScript strict checks in files by fixing errors, identifying code smells and refactoring code.
A set of 240 files to have typescript strict mode enabled and pass the typescript strict checks.
The following two milestones list the contributions made during and for the GSoC Project.
- The set of 117 files to have typescript strict mode enabled and pass the typescript strict checks.
- Update the existing guide on defining types.
Oppia plans to enable TS Strict mode for all of the files present in its code base as per the discussion #10327, hence there was a need to update the existing Guide on defining types to incorporate and identify recurring situations and errors that occur in the code when typescript strict mode is enabled. This is done so that we may refer back to these situations when a code change is made. The update made in the wiki can be found here.
PR Merged | No of files fixed |
---|---|
Fix Part of #10474: Cover more files with TS strict checks #12962 | 5 |
Fix Part of #10474: Cover some files with TS strict checks - 2 #13050 | 5 |
Fix part of #10474: Cover some files with TS strict checks - 3 #13043 | 3 |
Fix Part of #10474: Cover some files with TS strict checks - 4 #13047 | 3 |
Fix Part of #10474: Cover some files with TS strict checks - 5 #13057 | 10 |
Fix Part of #10474: Cover some files with TS strict checks - 6 #13263 | 21 |
Fix Part of #10474: Cover some files with TS strict checks - 7 #13270 | 20 |
Fix Part of #10474: Cover some files with TS strict checks - 8 #13293 | 39 |
Fix Part of #10474: Cover some files with TS strict checks - 9 #13304 | 11 |
- The set of 130 files to have typescript strict mode enabled and pass the typescript strict checks.
- Update config file for directories to have TS strict mode enabled by default.
PR Merged | No of files fixed |
---|---|
Fix Part of #10474: Cover some files with TS strict checks - 10 #13368 | 18 |
Fix Part of #10474: Cover some files with TS strict checks - 11 #13426 | 25 |
Fix part of #10474: Cover some files with TS strict checks - 12 #13520 | 19 |
Fix Part of #10474: Cover some files with TS strict checks - 13 #13555 | 23 |
Fix Part of #10474: Cover some files with TS strict checks - 14 #13578 | 22 |
Fix Part of #10474: Cover some files with TS strict checks - 15 #13598 | 23 |
Update tsconfig-strict to cover directories #13551 | N/A |
Fix Part of #13637: Remove interstitial Skills, SkillRights and Concept Card #13638 | N/A |
By the end of the project, 240+ files are fixed and 45+ directories have TS strict mode enabled by default in the oppia codebase.