-
-
Notifications
You must be signed in to change notification settings - Fork 480
[Tech] Let's be even more strict when writing TS code #1761
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
Conversation
These changes mostly boil down to: - Telling TS we're sure an array member will always exist since we're accessing it with an index gotten by `findIndex` before - Using already defined `window`/`mainWindow` variables instead of obtaining them again - Checking `unknown | undefined` values for being `undefined` first, before assigning them to something The syntax is still a little messy in places, I don't really like having to repeat `someArray[index]!` all the time. But that's something that can be improved some other time :^)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall.
Still have some questions/suggestions.
Arg, got caught by polymorphism here... |
These things are quite complicated, not sure why we didn't use the library since the start
Someone in the internet said checking for null also catches undefined. |
I ended up just using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is a lot of changes, will test it during the week.
Left a few comments for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
This makes them a little easier to read I've decided against putting them in a separate file, since they're used exclusively here. If that changes, having a `constants.ts` file might make sense Note that since the Epic Store URL is dynamic, depending on the language, I've added `$lang` to the string and replace any occurrences of it with the actual language once the URL is pulled from the object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me!
@CommandMC will still work on this one? |
I doubt I'm going to work on it anytime soon, might as well open up a new PR then |
I've changed some of our TS settings so we're forced to account for more situations that were easy to miss before. I think this will ultimately lead to a more stable experience for our users, at the cost of having to do a bit more work when writing new code
Changes in tsconfig.json:
allowUnreachableCode
:false
allowUnusedLabels
:false
noUncheckedIndexedAccess
:true
suppressImplicitAnyIndexErrors
(Just to clarify, these changes only cleaned up our config file, no functional changes were made)
noImplicitThis
: Alreadytrue
sincestrict
is enablednoImplicitAny
: Same as abovestrictNullChecks
: Same as aboveUse the following Checklist if you have changed something on the Backend or Frontend: