Jeevesh Garg
4 min readNov 21, 2022

Google Summer of Code 2022 with Oppia!

Free Education for Everyone

About Oppia

Oppia is an open-source company that wants to empower students all across the world by giving them access to excellent, exciting education. The platform from Oppia is especially made to cater to the distinct requirements of learners with limited resources all around the world.

About the project

Oppia frontend codebase is fully typed, but our typing doesn’t yet pass strict TypeScript checks. This means that variable assignment, procedure parameters, and function return values will all be clearly connected with a type.

Strict is a typescript compiler option that enables a set of tougher type rules that, when enabled, assist lower the possibilities of producing surprising outcomes and make the code more resilient, but Oppia’s code base presently fails to pass these stringent requirements. As a result, the code is vulnerable to unexpected actions and failures.

To avoid above, modify the strict TypeScript config file such that all newly-added files must be strictly typed. Earlier we need to add the path of the file in the files property of tsconfig-strict.json, which is now no longer supported after merge of PR, Enable typescript strict mode for all the newly added files and number of errors along with errors log. This is necessary step taken to apply typescript strictness rule to all newly added files, because we don’t want to always add files in tsconfig-strict.json forever. It also helps us to collect remaining files, which is further remove one-by-one.

Also Introduce strict typing for about 280 twins of files, as well as tests for those files (for a total of 560 files), and ensure that no more unknown type is used, as well as removing all unknown type usage from the newly strictly typed files.

Love Js/Ts
Love Js/Ts

Milestone 1

Change the TypeScript config file so that all newly-added files need to be strictly typed. Introduce strict typing for 280 frontend files (this number also can include test files).

Milestone 1 Pull requests:

  1. Fix part of #10474: Enable typescript strict mode for all the newly added files and number of errors along with errors log. [Pull Request #15578]
  2. Fix part of #10474: Make typescript checks strict for few more files. [Pull Request #15620]
  3. Fix part of #10474: Make typescript checks strict for few more files. [Pull Request #15799]

Milestone 2

Introduce strict typing for 280 additional frontend files in the codebase that were not covered in Milestone 1 (again, this number also can include test files). Remove the “unknown” type from all frontend files in the codebase, and add a lint check to prevent usage of “unknown” in the future.

Milestone 2 Pull requests:

  1. Fix part of #10474: Make typescript checks strict for few more files. [Pull Request #16214]
  2. MS-last(Improve frontend types): Remove Unknown and add lint check. [Pull Request #16597]

Future Plans

  1. Strict mode in TypeScript, as well as other strictness flags recommended by the TypeScript team. Specifically, strict, forceConsistentCasingInFileNames, noImplicitReturns,
    noFallthroughCasesInSwitch.
  2. Turns on strict Angular compiler flags strictTemplates and strictInjectionParameters.
  3. Reduced bundle size budgets by ~75%.
  4. Turns on no-any TSLint rule to prevent declarations of type any.

Conclusion

For me, this summer has been a fantastic time for learning. I experimented with a variety of development-related topics, ranging from writing functionality to testing, typings and debugging. Adjust the tsconfig-strict.json file such that any newly added files must adhere to strict type. It will be challenging for me to finish this since no one was able to offer a solution when the mentioned issue first surfaced last year.

What should you do if lengthy tests (CI/Local) are running and you are unable to perform anything? As your test results will show, further growth is likewise quite difficult.

I would like to express my gratitude to my mentors, Mridul Setia and Srijan Reddy, for their insightful comments and availability for conversations. It was enjoyable to work under.

Finally, the organization’s administrator with whom I connect the most is Sean. I used to meet and speak with him once every two weeks or more frequently as an onboarding lead. He is a person who appreciates perfection and is aware of how to get the most out of things. He sets up meetings, speaks with each Oppia team, and strives to make the flow smooth. He makes sure there are no barriers between the teams. It’s interesting to discover how he manages such a huge open source organization.

“Enjoying while code for community. Thanks!”