Live data from Hacker News

Using TypeScript with React

simonknott.de

191–195 of 195 posts

Re: Using TypeScript with React

#191
post #187
post #180

Earlier quoted context omitted.

Any method that mutates returns a copy, pretty easy to preserve immutability in OOP.

Then what do you do about the old version of the mutated object? There will still be references to it in other parts of your object model, which will now be out of date. I think that the concept of objects preserving identity is central to OOP, which simply contradicts immutability.

Could you give a concrete example?

Why would you somehow pass objects around that are not "final"?

I mean the objects that get pinned here and there are specifically designed to serve as wrappers for some state, hence they encapsulate that state, and thus they are mutable. (For example a DB connection/manager object, a service registry, a cookie/localStorage repository.)

Where the immutability usually helps is with shuffling data around, parallel computing (concurrent access, no need to lock), etc.

Re: Using TypeScript with React

#192
post #14

If you are going to learn a new programming language for web UI, why not go for Elm ? You get so much more than just static types with Elm.

To have a job maybe?

I got my current job precisely because of my interest in Elm, and it's been a great job.

Re: Using TypeScript with React

#193
post #15

If you are going to learn a new programming language for web UI, why not go for Elm ? You get so much more than just static types with Elm.

Elm is lovely, and I'd definitely encourage people to take a look at it from an education point of view at the least. However, I think that's a disingenous comparison. TypeScript is a superset of JavaScript, which means any JS dev already knows most of TypeScript. They're effectively just learning the type system and best practices on implementing it. The syntax of Elm is extremely different, which would effectively…

There are not many stories of integrating Elm to existing projects, but there are some. We at Conta AS integrated Elm in our big AngularJS application. So Elm work side by side with AngularJS. It’s possible to embed Elm program to AngularJS code, and it’s possible to embed AngularJS component to Elm program. Which makes the communication part easy. It’s true for any other technology such as React, Vue, etc..

Re: Using TypeScript with React

#194
post #14

Earlier quoted context omitted.

To have a job maybe?

I got my current job precisely because of my interest in Elm, and it's been a great job.

Well you are a minority then. I also love elm. I gave talks about it in meetups/confs and organized a local elm meetup but finding job as elm developer is extremely hard.

Re: Using TypeScript with React

#195
post #139

Earlier quoted context omitted.

this is why I wish typescript added runtime checks in development. Worst case, it would throw a TS error in your browser any time a function call or a network request didn’t match what you typed

you don't really want the overhead of checking types on every call, you know where your applications entry points are - if you need checks add them.

but I can’t add checks to the couple places I let users upload json for a form builder, for instance. No way to validate json with typescript natively. That would be awesome
Post reply on HN