4
Xoka
28d

React with JavaScript or TypeScript? and Why? Why not the other one?

Comments
  • 2
    Coffeescript
  • 1
    Depends on what you are comfort with. :) I don't think one is better than other.
  • 4
    @kristofersoler uhm yes it is, typescript and type safety are super important for scalability.

    Additionally the ecoworld of typescript is usually easier to work with. You can do a heck lot more wrong with vanilla js, especially if you are not 100% sure what you’re doing of have limited knowledge about it.
  • 2
    @010001111 hmmm... thats true. 🤔🤔 but that depends or what you are working on. Depends on the project and other things (like scalability).

    If I want to make a To-Do list I dont think one is better than other, just work with the language is more easy for you.

    Thats what I wanted to mean.
  • 4
    If you need to handle lots of business data from APIs, which in turn means you have to work with lots of complex objects, then typescript is a good candiate. Otherwise, you would have to do a lot more JSDoc.

    Typescript aid you in type safety, but this is only relevant at compile time. TS or not, you have to spend time type checking your stuff. TS will not guard you against cheeky API changes.

    JS is fine for smaller apps, but then again react is probably not the right framework choice there.
  • 2
    @kristofersoler I usually switch to typescript if I have more than 3 files that all correlate with each other, because you may not need ts for your todo app, but as soon as other feature come into, it’s wiser to start early than late

    But that’s my taste on that
  • 1
    Typescript is a pain in the ass when combined with React. Prepare for adding a lot of //@ts-ignore and prop:any types, or spend hours debugging chains of complex type structures extending one another.

    Eventually the result CAN be more robust code (in projects I've worked on, it seldom is). But regardless of whether it will be, it WILL impose a cognitive overhead. E.g. you have to think of every React event listener: wait, is this a React.SyntheticEvent, MouseEvent or KeyboardEvent.. What if it gets executed with different events?

    As for documenting methods and parameters, JSdoc is good enough and, unlike Typescript, does not block your build or spam warnings when you leave one undocumented.
  • 3
    I’m a big fan of Typescript, and can confirm what others said here.
    What makes you stick to React ? Have you considered other Frameworks, if you can ? I’m very happy with vuejs.
  • 0
    Typescript good
    Scala good
    Flow good

    Vanilla js and coffeescript will cause you extra bum hair
  • 0
    I use typescript for the autocomplete lol
  • 0
    Typescript. Because the compiler will moan at you more than your clients when shit dun wurk
Add Comment