Skip to content

fix: add initialization variables to fix typescript strict mode errors. #2824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Jasonlee6789
Copy link
Contributor

npx tsc --strict:

Found 1522 errors in 194 files.

Found 1505 errors in 196 files.

Copy link

codecov bot commented Sep 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Additional details and impacted files
@@              Coverage Diff              @@
##             develop    #2824      +/-   ##
=============================================
+ Coverage      56.65%   59.07%   +2.43%     
- Complexity      8914     8918       +4     
=============================================
  Files           2167     1905     -262     
  Lines          91939    85257    -6682     
  Branches        6833     5807    -1026     
=============================================
- Hits           52081    50360    -1721     
+ Misses         37983    33100    -4883     
+ Partials        1875     1797      -78     

@@ -57,6 +57,10 @@ export abstract class AbstractHistoryChart {
borderColor: "rgba(128,128,0,1)",
};


private activeQueryData: string = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review. In my opinion, this change is necessary to meet TypeScript's strict property initialization rule.
By initializing activeQueryData, it ensures it is always defined, after this change, this place TypeScript strict mode error was reduced. Without this explicit initialization, the compiler generates an error because it cannot guarantee that activeQueryData will have a value before it’s used.

@lukasrgr
Copy link
Contributor

@Jasonlee6789 thx for your contribution, im not sure, if this PR has some purpose

@Jasonlee6789
Copy link
Contributor Author

Jasonlee6789 commented Mar 12, 2025

@Jasonlee6789 thx for your contribution, im not sure, if this PR has some purpose

Thank you for your review. The purpose of this PR is to fix uninitialized variables in the UI code and explicitly add null type annotations to variables initialized as null, in order to fix TypeScript strict mode errors and prevent potential runtime errors.
The result of this PR is that after running npx tsc --strict, the number of errors was reduced from 1522 to 1505, eliminating 17 errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants