Skip to content

Instantly share code, notes, and snippets.

@mridul-netizen
Created August 29, 2021 18:43
Show Gist options
  • Save mridul-netizen/1f25e7cd2e09cd2269cf571e6806741c to your computer and use it in GitHub Desktop.
Save mridul-netizen/1f25e7cd2e09cd2269cf571e6806741c to your computer and use it in GitHub Desktop.
Issue- Making typechecks strict

Currently, in our tsconfig.json we don't have strict rule enabled. But as per discussion in #10327 we have decided to enable this rule. We can't do this at once because of a huge number of errors. So, we've decided to do it gradually file by file. For reference on what does strict rule do you can look for --strict here.

  • You can once go through this guide for getting started with types.

  • This guide covers most of the cases encountered in our codebase which throws strict typing errors, along with their solution.

To be assigned to a file or for any queries feel free to comment on the thread.

Steps to fix this issue

  • Find the path of the service. For example, for AdminRouterService it is core/templates/pages/admin-page/services/admin-router.service.ts.
  • Add the path of that service in the files property of tsconfig-strict.json.
  • Add the path of the service spec file in the files property of tsconfig-strict.json.
  • Run python -m scripts.typescript_checks --strict_checks
  • Fix the errors shown. Note that there may be no errors and you may have to refactor the code a bit to fix the errors (if present).

PRs for reference

#10485, #10724

If you want to be assigned to some file please ping @vojtechjelinek

Services to be covered by strict checks

  • extensions/interactions/base-validator.spec.ts (need to be migrated first)
  • core/templates/services/compute-graph.service.ts @msrijita18
  • core/templates/domain/improvements/exploration-improvements-config.model.ts @soumyo123-prog
  • core/templates/domain/exploration/exploration-permissions-backend-api.service.ts @juanapatankar
  • core/templates/domain/feedback_message/feedback-message-summary.model.ts @manishaag7
  • core/templates/pages/profile-page/profile-page-backend-api.service.ts @klenathstar
  • core/templates/services/improvements.service.ts @ehwu
  • extensions/interactions/MusicNotesInput/directives/music-phrase-player.service.ts @christinetsai
  • extensions/interactions/CodeRepl/directives/oppia-response-code-repl.component.ts @PranshuSrivastava
  • core/templates/services/image-upload-helper.service.ts @leylatuon
  • core/templates/pages/contributor-dashboard-page/services/translate-text.service.ts @ShivamJhaa
  • core/templates/pages/profile-page/profile-page.component.ts @aniketh-varma
Services covered by the strict checks
  • AnswerGroupObjectFactory
  • GraphUtilsService @stephen-hannon
  • ExplorationFeaturesService @rodemore
  • MathEquationInputRulesService @rodemore
  • MisconceptionObjectFactory @rodemore
  • NumericInputRulesService @Nisarg-Chaudhari
  • SetInputRulesService @EeshaArif
  • SchemaFormSubmittedService @EeshaArif
  • StateEditorRefreshService @EeshaArif
  • StateNameService @EeshaArif
  • StoryNodeModel @EeshaArif
  • GuestCollectionProgressObjectFactory @eightballocto
  • NeedsGuidingResponsesTaskObjectFactory
  • CollectionPlaythroughObjectFactory @Nisarg-Chaudhari
  • CollectionRightsObjectFactory @Nisarg-Chaudhari
  • CollectionSummaryObjectFactory @Nisarg-Chaudhari
  • AdminRouterService
  • AngularNameService @nishantwrp
  • LearnerParamsService @ehwu
  • AdminTaskManagerService @nishantwrp
  • AnswerClassificationResultObjectFactory @Nik-09
  • AugmentedSkillSummaryObjectFactory @tushar2407
  • AlgebraicExpressionInputRulesService @nishantwrp
  • AppService @anandwana001
  • AudioLanguageObjectFactory @tushar2407
  • BackgroundMaskService @Purhan
  • BrowserCheckerService @Purhan
  • AssignedSkillObjectFactory @arpit1912
  • AudioBarStatusService @arpit1912
  • AudioFileObjectFactory @arpit1912
  • CamelCaseToHyphensPipe @arpit1912
  • ClientContextObjectFactory @Nik-09
  • ComputationDataObjectFactory @tushar2407
  • CountVectorizerService @dsandeep0138
  • CsrfTokenService @shrutigrover
  • DateTimeFormatService @shrutigrover
  • ExpressionParserService @anandwana001
  • FeaturedTranslationLanguageObjectFactory @anandwana001
  • DebouncerService @rodemore
  • DragAndDropSortInputRulesService @aishwary023
  • EditabilityService @aishwary023
  • EmailDashboardQueryObjectFactory @aishwary023
  • EntityContextObjectFactory @Nik-09
  • FractionObjectFactory @Rijuta-s
  • I18nLanguageCodeService @iramin
  • AutoplayedVideosService @adi2011
  • LoaderService @arora-ria
  • LoggerService @arora-ria
  • CodeNormalizerService @krishita30j
  • IdGenerationService @krishita30j
  • ConstructTranslationIdsService @krishita30j
  • AutogeneratedAudioLanguageObjectFactory @Rijuta-s
  • ExternalSaveService @Rijuta-s
  • FileDownloadRequestObjectFactory @Rijuta-s
  • CreatorExplorationSummaryObjectFactory @mridul-netizen
  • CreatorDashboardStatsObjectFactory @mridul-netizen
  • ClassifierObjectFactory @jassi-singh
  • LogicProofRulesService @parulpriyedarshani
  • AnswerStatsObjectFactory @YashJipkate
  • AudioTranslationManagerService @YashJipkate
  • ContinueRulesService @YashJipkate
  • EndExplorationRulesService @YashJipkate
  • ExplorationOpportunitySummaryObjectFactory @YashJipkate
  • ImageClickInputRulesService @YashJipkate
  • InteractiveMapRulesService @akshathkaushal
  • ParamChangeObjectFactory @michaelw54
  • InteractionDetailsCacheService @akshathkaushal
  • GraphDetailService @jassi-singh
  • NormalizeWhitespacePunctuationAndCasePipe
  • ItemSelectionInputRulesService
  • MultipleChoiceInputRulesService
  • core/templates/domain/exploration/InteractionObjectFactory.ts @YashKandalkar
  • core/templates/domain/exploration/SolutionObjectFactory.ts @YashKandalkar
  • core/templates/domain/exploration/WrittenTranslationObjectFactory.ts @YashKandalkar
  • core/templates/domain/exploration/exploration-draft.model.ts @YashKandalkar
  • core/templates/domain/objects/NumberWithUnitsObjectFactory.ts @YashKandalkar
  • core/templates/services/extension-tag-assembler.service.ts @YashKandalkar
  • core/templates/domain/feedback_thread/feedback-thread-summary.model.ts
  • core/templates/domain/platform_feature/feature-status-summary.model.ts
  • core/templates/domain/exploration/exploration-metadata.model.ts
  • core/templates/domain/improvements/high-bounce-rate-task.model.ts

NOTE: The above list is not the complete list of services that should be covered. These are some of the services present in topological level 0 in UpgradedServices.

Tips

You may not be able to see the strict typescript errors in your IDE. To see them you can change

"noImplicitUseStrict": true,

to

"strict": true,

in tsconfig.json

Also, if you are seeing typescript errors in files other than the files mentioned in files property of tsconfig-strict.json on running python -m scripts.typescript_checks --strict_checks. That is because that file may be imported by one of files in tsconfig-strict.json. If the dependency is complex and has other dependencies itself, you can leave that file for now and work on any other service . Please mention that here if you are doing so. We can cover that file after we cover it's dependencies.

Note: For a guide on how to access Oppia's webpages, see this.

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