-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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. |
|
|
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:
|
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Payment Summary
BugZero Checklist (@adelekennedy)
|
Payouts due:
@ShridharGoel sent you an offer in Upwork |
@adelekennedy Thanks for checking payment of this task. I'm not sure if we're eligible for the full payment of this job because the task was reassigned in the middle of the last PR, see here #43055 (comment) I think it'll be better to wait for @roryabraham 's input before issuing the payment. |
Oh thank you @eh2077 I totally missed that (this issue has gotten pretty dense) Rory is out on parental leave so I'm making a call based on all the comments above - I think an even split here may be the most fair between you and @ShridharGoel? |
@adelekennedy Personally, the payment of $500 is fair. Thanks! Just one more question, can I request payment through NewDot instead? |
@ShridharGoel, @roryabraham, @adelekennedy, @zfurtak, @eh2077 Eep! 4 days overdue now. Issues have feelings too... |
@eh2077 yes! I just withdrew the offer on Upwork and updated the payment summary above |
Thanks! Requested in NewDot. |
closing this for now - @ShridharGoel I will pay you once you accept in NewDot |
$500 approved for @eh2077 |
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: