-
Notifications
You must be signed in to change notification settings - Fork 179
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
Adopting TypeScript #1715
Comments
Thanks for posting your proof of concept here with the tracking package! So, I'm not the most familiar with typescript in a prod environment, I use it sparingly in my own time and have taken a handful of classes on it. @littlemilkstudio and @samwhale are both well versed in it and worked with it before this project within Formidable at another client. That said, it feels like we're at the point where this is a really good idea to dig into more. Specifically, I think converting the story/element data structure and media resources (which you pointed out already) would be really helpful in moving to a shared state solution and then further down the road as we look into replacements for draft js. Having the story structure strongly typed so that the whole of it is defined before we make those moves would make the code stronger along the way, preventing weird edge case regressions. It's also going to help give context to devs who didn't write the base structure. My thought is that we should come up with a list of qualifications for when to migrate something to typescript, this would give us a way to track what we need to update and then that list of qualifications can become an identifying pattern for when new code gets written too. Also, probably starting on the smaller, frequently used packages (as Pascal did with the POC tracking) would work well (not to just completely echo @swissspidy here). I can safely say that pea pod would be really excited to work on this update. @littlemilkstudio @samwhale ya'll wanna chime in with thoughts/ideas? |
Yup yup. this sounds good to me. My only advice is that it's easy to import something written in TS into JS, but it's not so nice to import JS into TS. Downsides of importing JS into TS include:
Any adoption strategy that is aware of this will probably fare well. The low-level code you mentioned seems like a good candidate here for these reasons |
I recall previous discussions about starting with migrating leaf packages first, which would align with that 👍 So overall we're on the same page I think. A list of qualifications sounds good to me, though this can probably wait until after a concerted effort to migrate the core data structure, which would be prio no. 1. Speaking of, protocol buffers might be the best source of truth for that. It's what we typically use internally. We experimented with that previously in #1044. There are code generators such as https://github.com/stephenh/ts-proto to automatically create TS interfaces from |
Feature Description
Possibly adopting TypeScript for our code base has been brought up a few times in the past.
A step in that direction was made at some point by switching our JSDoc parsing to use TypeScript, allowing for more expressive type documentation. See #2960.
That's a pretty common thing to do and is something Gutenberg has been doing as well, for example. Gutenberg even creates
d.ts
files based on the JSDoc annotations. That's neat because it improves DX without actually having to write TypeScript code. That path has its limits, however.Actually authoring code in TypeScript is of course a whole different topic.
My proposal is not to just convert our hundreds of thousands of lines of code to TypeScript. However, TypeScript could be selectively used for some parts of the code base.
In particular, I think it would be really helpful for low-level code that does not require frequent maintenance. For instance:
Resource
,createResource
)tracking
,i18n
orurl
that change rarely but are used oftenSome considerations off the top of my head:
Other benefits:
Overview
date
dom
i18n
media
moveable
patterns
react
stickers
transform
tracking
units
url
Additional Context
Gutenberg went through a similar process. These posts are a great resource on that:
The text was updated successfully, but these errors were encountered: