Skip to content

Instantly share code, notes, and snippets.

@EeshaArif
Created August 19, 2021 16:28
Show Gist options
  • Save EeshaArif/53016604eae2abb89355b8725f914c0a to your computer and use it in GitHub Desktop.
Save EeshaArif/53016604eae2abb89355b8725f914c0a to your computer and use it in GitHub Desktop.
Google Summer of Code 2021 -- Improve Frontend Type System

GSoC'21 Improve Frontend Type System

Introduction:

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.

Key Objective:

A set of 240 files to have typescript strict mode enabled and pass the typescript strict checks.

Implementation:

The following two milestones list the contributions made during and for the GSoC Project.

Milestone 1:

Description:

  • The set of 117 files to have typescript strict mode enabled and pass the typescript strict checks.
  • Update the existing guide on defining types.

Wiki Update:

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.

Code:

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
Total Files with errors Fixed: 117

Milestone 2:

Description:

  • 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.

Code:

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
Total Files with errors Fixed: 130

Conclusion:

By the end of the project, 240+ files are fixed and 45+ directories have TS strict mode enabled by default in the oppia codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment