1km.co.il
1km.co.il copied to clipboard
TypeScript
If interested, I can add TypeScript support to the project. This will make it easier to make sure things don't break when other people work on the codebase.
Hi :-) I don't have lots of experience with TS but I'm open to use it in the project. Let's wait with this for next week to see where we're at.
Btw - do you think there's a chance it'll prevent newcomers from joining the project? (devs without TS knowledge)
To be honest, yes, I think that this can add some friction to people without any prior TS experience, especially on more complex and non-trivial features.
On the other hand, I believe that most of the experienced frontenv devs that worked on bigger projects will be familiar with TS at some level. From my personal experience, once a project grows to more than a few hundreds lines of code, TS has a positive ROI (meaning that it overall saves more time than you spend on it), and the ROI grows as the project gets even larger.
Anyway, I'm available if/when you want.
Maybe just add type definitions? Personally I believe TS can be a blocker for new devs, but there are ways to achieve type safety without changing all the way, right?
TS can be added gradually, but from my experience: if you don't intend to eventually go TS all the way, and you don't have very disciplined developers in the team, then the types soon or later get out of sync and become a burden instead of an asset.
It's a bit like doing DOM manipulation in React instead of using JSX. You can get away with it once or twice, but if you allow this to become a habit, it will get out of control and you'd end up with more mess than if you haven't used React at the first place.
I think TS would be a net positive for the project, but maybe for now we could add propTypes? That will achieve type safety without adding the complications TS poses to devs inexperienced with it.
I also think adding TS is a net positive. Simply having the ability to use it will accelerate development to some degree as well as invite over some developers that shy away from plain JS..
propTypes might be easier to start with but over time they are more cumbersome to maintain to some degree.
@markVaykhansky I agree. I see propTypes as a temporary crutch. When we decide to move to TS we could get rid of them. But for now they could be useful.
There's no real difference between adding proptypes and adding TS. If all we want is to type component props that's very simple:
interface Props {
initialCoords: { lat: number, lng: number };
type: string;
}
function SomeComponent(props: Props) {
}
and you'll have the ability to type regular functions too (which you can't do with proptypes). I think TS is a must in a project with a large of amount of devs that aren't familiar with the codebase, and especially for a website with this scale.
Since we're on CRA, adding it should super simple
I say let's do it. We won't be hurting new devs but rather saving them from breaking the app, and we could have the confidence to add more junior devs to the project.
+1 for TS
Yalla. Who wants to take this? How will this affect our open PRs?
I feel like the "other side" wasn't heard enough. Most of the pro TS here just dismiss the fact that TS is a hurdle that will push non-TS devs away. Just another thing to think about
As numbers of contributers grow, and there are no unit-tests, bugs and crashed are waiting to happen. Either adding tests or TypeScript will make the app more resilient. I think TypeScript has better ROI.
@idanen Disclaimer: I have never used TypeScript in a project, just played with it for a day or so.
It seems like there's pretty much consensus among contributors who have worked with the source code in this discussion. They might a bit biased as they're both experienced developers and have already used TS in the past, but it's important to remember that the project have a dead line, which is not far away (between a week - month), so if they say it'll make them work faster - I stand with them.
Who knows, we might pivot the project to have another purpose after lockdown, so it might be wise to think about the learning curve and how we can attract more contributors. But for now our main goal is to be very fast in order to push the protest movement, under the current conditions, to new heights.
In that case (deadline, no TS experience), adding TypeScript will slow down the progress and I would stick to what you know and works for now.
Yeah, I get what you're saying. I won't have time to learn TypeScript at the position I'm at currently. But right now I'm rarely writing new code, and tend to give much more responsibilities to other maintainers as they progress.
So I don't know. I feel it's much more the active contributors and maintainers decision than mine.
If the intent is to eventually add TypeScript, then there's a way to do it progressively, which should have a low impact on the pace of the project, while still getting some of the benefits:
- Set up TypeScript, enable
allowJs
, disable typechecking for libs - Slowly add type annotations to existing JavaScript files (as JSDOC comments)
- For new files, prefer
.ts
over.js
- Once we feel comfortable, start enabling more strict typechecking (noImplicitAny, strictNullChecks, etc.)