-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[HOLD for payment 2024-10-10] [$1000] Enable the noUncheckedIndexedAccess TS compiler option #43055
Comments
Triggered auto assignment to Contributor-plus team member for initial proposal review - @eh2077 ( |
Triggered auto assignment to @adelekennedy ( |
It's worth noting that when enabling this rule we get more than 1000 errors across more than 200 files, so in order for me to accept a proposal it would need to include a rollout plan so we can incrementally adopt this new rule across a subset of files at a time. |
ProposalPlease re-state the problem that we are trying to solve in this issue.Enable the noUncheckedIndexedAccess TS compiler option. What is the root cause of that problem?New change. What changes do you think we should make in order to solve the problem?We need to enable the noUncheckedArrayAccess TypeScript config.
Once noUncheckedArrayAccess is enabled, TypeScript will infer the type of an array access expression as including undefined. For example, accessing an element of an array myArr: MyType[] at an arbitrary index will be inferred as MyType | undefined. On enabling:
Add a unit test:
Incremental adoption: Add it only to some files or some modules can be done by using a new
One by one we can keep adding modules. Once most of the files are updated, we can include the check in |
@ShridharGoel Thanks for your proposal. How will the new |
We can use something like |
This comment was marked as off-topic.
This comment was marked as off-topic.
That sounds reasonable. So the rollout plan would look something like this:
tsc && tsc -p tsconfig.uncheckedindex.json
sounds good, the only other thing I'd like to figure out is how we want to break it up into reasonably-sized PRs. Some of these might be a bit trickier than your standard TS migration, because it actually involves changing runtime code. Going to assign this one a bounty of $1000 because it's going to be a few PRs. |
|
@ShridharGoel I look forward to reviewing the first PR. |
This issue has not been updated in over 15 days. @ShridharGoel, @roryabraham, @adelekennedy, @eh2077 eroding to Monthly issue. P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do! |
At this point, the last PR has been dragging on too long without enough proactive or responsive communication. As such, if it is not merged within the next one or two days, we are going to reassign this issue |
@ShridharGoel, @roryabraham, @adelekennedy, @eh2077 Uh oh! This issue is overdue by 2 days. Don't forget to update your issues! |
@ShridharGoel, @roryabraham, @adelekennedy, @eh2077 Huh... This is 4 days overdue. Who can take care of this? |
As it was decided in the slack discussion I will take over this issue |
Hi, this task is almost complete. The only thing to look into is the perf test issue (which seems to be happening only on CI), so I'm not sure if another assignment is needed.
|
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results. If a regression has occurred and you are the assigned CM follow the instructions here. If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future. |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.43-6 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2024-10-10. 🎊 For reference, here are some details about the assignees on this issue:
|
BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
Slack proposal: https://expensify.slack.com/archives/C01GTK53T8Q/p1717468504413819
Problem
We currently have crash occurring on production. The problematic code can be summarized with a minimal example:
As you can see, we unsafely indexed an array, and then assumed the result was defined. Then trying to access a property of
undefined
, we experience a crash.Solution
Enable the noUncheckedArrayAccess TypeScript config. With that config enabled, the type of
myItem
is correctly inferred toMyType | undefined
, and we get a compiler error when trying to accessmyItem.something
, preventing the crash at compile time.Issue Owner
Current Issue Owner: @adelekennedyThe text was updated successfully, but these errors were encountered: