Closed roryabraham closed 1 month ago
I have read and reviewed this Design Doc!
Is this a super high priority? It looks like it was created with a Daily tag for everyone to review in one day, which normally we reserve for things that are impacting the next couple waves. @danielrvidal
This issue has the "daily" label because this project involves external vendors who already started working on some tasks. Migration is one of those projects that don't have a clear deadline. But they're also the kind of projects that benefit from a short lifespan.
As this design dos is rather short, we thought we could justify requesting reviews with the daily label ๐
I have read and reviewed this Design Doc!
I have read and reviewed this Design Doc!
I have read and reviewed this Design Doc!
I have read and reviewed this Design Doc!
I have read and reviewed this Design Doc!
I have read and reviewed this Design Doc!
I have read and reviewed this Design Doc!
I have read and reviewed this Design Doc!
We've seen good activity and detailed reviews have been moving along nicely.
The detailed review is done ๐
Here are the next steps.
For the assignment and division of tasks and tracking of subtasks of these four tasks, we delegate them to SWM and CallStack. Please communicate with each other to divide responsibilities ๐ @fabioh8010 @blazejkustra
For each of these four tasks, I created a GH issue. We'll eventually put these issues inside a GH Project we'll create for the TypeScript migration. Please report any progress in the respective issue.
I provided rough deadlines for each task. These are more like guidelines rather than strict deadlines. Please provide your own estimate on the completion time of the task in the issue itself.
A rough overview of the guideline is in the design doc. Let's create the first version of the guideline in app/contributingGuides/TYPESCRIPT_STYLE.md
Let's add succinct code examples as needed. Create sub-files if necessary to divide the guideline into sections.
Please write the guideline following conventions widely used in open-source communities and also those already used in other guidelines in App (ex. usage of shall, should, or must).
Create type definitions for react-native-onyx and expensify-common. Until these definitions are complete, we cannot move to the migration of App.
react-native-onyx GH isssue: https://github.com/Expensify/react-native-onyx/issues/260
expensify-common GH issue: https://github.com/Expensify/expensify-common/issues/547
@fabioh8010 is already testing GitHub's Project feature and figuring out how to create migration issues.
@neil-marcellini, @roryabraham, @hayata-suenaga Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
The PR to set up the app for typescript is under review and I just finished my review. I'm eager to keep helping out mostly by reviewing.
The main PR to integrate TypeScript toolchain into E/App is in review. Exciting!
I started reviewing the Typescript guidelines PR today.
PR with type definitions for expensify-common
is ready here. Please check it out! ๐
With amazing work by @fabioh8010 and @blazejkustra, we're on a good track ๐ There are the latest updates!
expensify-common
is under reviewreact-native-onyx
The TypeScript GH Project now has the public visibility
@neil-marcellini, @roryabraham, @hayata-suenaga Whoops! This issue is 2 days overdue. Let's get this updated quick!
A new PR for TS guidelines was created, and I expect the review to be finished by the end of this week.
@fabioh8010 is working on creating type definition files for react-native-onyx
script for creating GH migration issues is ready
We should start thinking about typing core data. The PoC PR for this is already made here by @thiagobrez.
cc: @fabioh8010 @blazejkustra
We're planning to merge the expensify-common PR by EOD and the App set up PR by EOW.
I have read and reviewed this Design Doc!
react-native-onyx
PR is in progress.expensify-common PR
has been merged.Requested internal engineers' review on the core data PR in NewDot here.
Progress is ongoing. We were discussing a related change (that can happen separately from the main TS migration) in these threads:
I personally think the most significant decisions that are being made are how we are typing react-native-onyx, and I sadly am not up-to-date on the latest there
the most significant decisions that are being made are how we are typing react-native-onyx, and I sadly am not up-to-date on the latest there
@roryabraham
The draft PR for creating definition files in Onyx is going here.
useOnyx
along with the TS migration. The discussion is happening hereuseOnyx
during TS migrationHad a sync with @hayata-suenaga today. The main action item at the moment is getting all the reviews in for this big PR
TS guideline is almost ready. Lets merge it by the end of this week and announce it on the open source channel so that contributors will have time to look over the guideline before the migration starts (migration tasks will be only opened to contributors in the later stage of the migration, but they might encounter merge conflicts and have to edit TypeScript code)
Onyx + TS PR is still being actively reviewed and worked on. Let's aim to merge this by the end of Wednesday next week ๐
@blazejkustra let us know if you need more help from internal engineers for the core Onyx data + TS PR. Seems like all files are reviewed by internal engineers at least once.
Let's run the script to create all migration tasks once the Onyx + TS PR and core Onyx data + TS PR are merged next week.
(internal) We probably have to edit the Web-E review process to update the core Onyx data typing when the shape of backend data sent to App changes. @roryabraham , @mountiny, and @neil-marcellini do you have any idea how we can make sure that engineers are reminded to update the TS type definitions for Onyx data when the backend data shapes change?
@roryabraham , @mountiny, and @neil-marcellini do you have any idea how we can make sure that engineers are reminded to update the TS type definitions for Onyx data when the backend data shapes change?
I am not sure, maybe some action/ webhook analyzing the code changes
@blazejkustra @fabioh8010 any recommendations?
@roryabraham , @mountiny, and @neil-marcellini do you have any idea how we can make sure that engineers are reminded to update the TS type definitions for Onyx data when the backend data shapes change?
I am not sure, maybe some action/ webhook analyzing the code changes
@blazejkustra @fabioh8010 any recommendations?
So, there are couple of ways to do it:
@mountiny I was asking how we can change the internal process (add new checklist item, etc) for Web-E PRs so that engineers are reminded to change the type definition of the backend data changes.
should we just edit the PR template for Web-E? Should we also add a checklist for Auth
, too?
@hayata-suenaga I am curious though if checklist will be enough to check for this. I think we can start with it and see if we will have people ignoring it
@mountiny yes I think the option #2 @blazejkustra suggested is something we want to consider down the line
but I'm thinking something we can implement right now that at least do something toward ensuring type consistency between front end and backend.
I created an internal issue to update templates for Web-E and Auth PRs, I gonna make PRs for them today
@roryabraham , @mountiny, and @neil-marcellini do you have any idea how we can make sure that engineers are reminded to update the TS type definitions for Onyx data when the backend data shapes change?
I think we should punt this problem (or maybe rumor of a problem) for now and just focus on getting TypeScript built out in a leaner V1. Long-term I love the idea of having a shared, versioned schema for Onyx used by both the front-end and back-end to automate the compatibility between layers. But I feel strongly that we're getting ahead of ourselves here.
We don't currently have anything to ensure Onyx schemas are compatible in the front-end and back-end, and it's been working mostly ok. The amount of type safety we'll get in the front-end alone will be a huge win.
FWIW, if someone's updating something in Onyx in PHP, they'll probably try to access that property in E/App, and notice that the type is wrong. I kind of think that's enough to start.
That said, if we're going to do anything I agree with @mountiny's suggestion that we can add a webhook comment on API PRs like:
I noticed that you changed some code that has to do with Onyx. Did you adjust the Onyx schema? If so, make sure you adjust the corresponding Onyx type declaration in E/App.
We could probably do that pretty easily but I don't think it should be a top priority for this project.
Will merge the guideline PR this afternoon and post the announcement
I'm continuing to review the PRs to type Onyx data in App and to add type declarations for Onyx. Both are very close I think.
#expensify-open-source
and #engineering-chat
(internal) slack channelsOnce the above two PRs are merged, we can execute this script to create migration GH issues and officially kick off the TS migration.
I realized there are additional libraries being developed right now at Expensify for App
We probably have to rewrite them in TypeScript or write TS definitions for them at some point. Just a note. I'll keep track of the related project and update here.
The review for https://github.com/blazejkustra/App/pull/1 progresses a lot thanks to @neil-marcellini. What is the time estimate for this PR to be merged?
@hayata-suenaga There is a TODO list in the description of the PR explaining whatโs left. Currently the only blocker is react-native-onyx PR, once it's merged, Iโll install the typed version of Onyx and the PR should be ready.
I created a GH issue to dump notes on things we have to remember during the migration. Please feel free to post anything as notes to the issue.
[ ] A performance issue with TypeScript Intellisense was discovered in the App TS Setup PR. One source of the issue was identified and fixed. @blazejkustra is working on the second source of the issue. The latest update is here.
[ ] Fabio has done amazing work so far with Onyx + TS PR. He's finalizing on some details of the PR but it's very close to the finish line ๐ฅณ
[ ] @Blajez addresses all PR reviews swiftly and Onyx core data PR is ready. Please give a final look and approve it if it looks good. The PR is, however, on hold for #20179 (the App TS Setup PR).
Also, Blajez, the PR is for your own branch. could you make a PR for the main branch of App? <img width="400" alt="Screenshot 2023-07-28 at 10 51 28 AM" src="https://github.com/Expensify/App/assets/98560306/777520a4-273d-49c0-a344-6bf6a09fcb08"
Heads up, I'm going to be OOO Monday and Tuesday next week so please don't let me be a blocker for anything while I'm out.
Update from @blazejkustra today here
Expensify/App
, here is a brand new PR. It is blocked by https://github.com/Expensify/react-native-onyx/pull/267. After react-native-onyx
& Onyx type core data
PRs are merged, we can proceed to phase 2 of Typescript migration! ๐
I didn't do end of week update last week ๐ญ but it's already time for...
Once the App Setup PR is merged, then we're officially and finally ready to start migration.
We first have to run this script (sorry internal link) to create GH migration issues in the TS migration project (this one should be public link).
If I remember correctly, we will start migration from leaf files and the first phase of the migration is conducted only by CallStack and SWM engineers. Checking with @blazejkustra and @fabioh8010 how these expert agencies plan to coordinate with each other in allocating issues.
Onyx PR: Create type declaration files Merged ๐ฅณ ๐ฅณ ๐ฅณ ! Thank you so much @fabioh8010 and @blazejkustra for your amazing work on this one
App PR: Type core data As @blazejkustra described https://github.com/Expensify/App/pull/24054 and as I described in this slack message, there was a major update in Onyx and the version is being bumped in App in https://github.com/Expensify/App/pull/24054 which changes APP code to work with the major change in Onyx. So we have to hold our PR for it.
Once the App Setup PR is merged, then we're officially and finally ready to start migration.
Next week, we gonna run this PHP script (internal link) with the updated CSV file that @fabioh8010 is going to provide to create migration issues.
In the initial phase of the migration:
SWM and CallStack are going to coordinate with each other to assign issues to themselves.
We have to make sure that engineers from these organizations have permissions to assign themselves to issues on GH.
Additional Note: @blazejkustra and @fabioh8010 are OOO on next Monday and Tuesday
Here is the latest update in the issue that is blocking @blazejkustra's Onyx core data App PR. The blocking PR hasn't been merged yet.
Once the above PR is merged, we gonna also merge this PR that adds a new checklist item in the backend PRs (Web-E and Auth) to encourage engineers to update the Onyx Data TS definitions if they change data shape.
Once @fabioh8010 returns from OOO, we can run this PHP script (internal link) to create GH issues for migration tasks with the updated CSV file that @fabioh8010 is going to provide us.
Also, we were originally planning to de-structure component props before the migration starts, but the --fix
for eslint
didn't work well with the react/destructuring-assignment
rule, and I could't de-structure props in batch. So we have to manually de-structure components when migrating to TS.
I believe this rule is not currently turned on for TS files. So I gonna open a PR for it so that ESLint warns if we forget destructure props when migrating.
Proposal: Utilize TypeScript to reduce bugs in NewDot
๐ Link to the design doc
docs.google.com/document/d/1LNcgYeYyovQ88gNjLIgBqBReLtbLAbxeAbna9QKxeAQ/edit#
๐๏ธ Other links
Strategy
Our strategic roadmap for the next couple years is Reunification โ moving all of our existing users from OldDot to NewDot, and itโs going to look like a completely new product. During this transition period, thereโs an increased risk for churn, and stability of the platform is more important than ever. Any lines of defense between our customers and bad code will pay dividends during any tumultuous times to come.
Problem
JavaScript has been very popular for front-end development for a long time, and over the years it has evolved with new developer-friendly features that make it easier to GSD. Overall, itโs pretty great. However, it is still plagued by one fundamental problem: runtime errors stemming from incorrect types. This common class of problem leads to bugs, ranging in severity from showing weird things on the screen to crashing the whole app.
While there are many bugs that can be caused by incorrect types, the most common example of a runtime type safety error is
Cannot access property X of undefined
. A quick GitHub search reveals that over the last couple years we have introduced hundreds of this type of bug into the NewDot codebase, each of them stemming from this same root cause โ attempting to access a property on a variable whose value isundefined
. When this occurs, the app crashes.Solution
Let's commit to adopting TypeScript in New Expensify, an awesome superset of JavaScript that gives us the benefits of using a compiled language like C++! That way, type errors can be caught at compile-time instead of run-time, and a whole class of common bugs will be eliminated from our product. #BugZero here we come.
Furthermore, letโs engage the near-limitless capacity of our open-source community to do it in parallel to our existing roadmap, without pausing any other feature development in the meantime.
Tasks
#expensify-open-source
strategy@expensify.com
and paste in the Proposalstrategy@expensify.com
(continue the same email chain as before) with the link to your Design Doc#expensify-open-source
to discuss any necessary details in public before filling out the High-level of proposed solution section.stategy@expensify.com
again with links to the doc and pre-design conversation in SlackDesignDocReview
label to get the High-level of proposed solution section reviewed#expensify-open-source
to ask for engineering feedback on the technical solution.DesignDocReview
label to this issuestrategy@expensify.com
one last time to let them know the Design Doc is moving into the implementation phasestrategy@expensify.com
once everything has been implemented and do a Project Wrap-Up retrospective that provides: