Earlier quoted context omitted.
> There are no downsides but so many upsides I've not used TS, but from what I've read the types from TS are not js compatible, so once you go into TS you have code that just isnt js. (As opposed to flow, where you can just have it not be used) While transpiling is normal, I'm as hesitant to tie myself to TS as I am to, say, a non-standard decorators syntax. Anyone coming to me with "there are no downsides" in such a…
I'm not sure what you mean by "not JS compatible" here. TypeScript obviously compiles into JavaScript, and any valid JavaScript is also "valid" compilable TypeScript (the compiler will complain, but it will still compile it into JavaScript that does the same thing). With the right assertions (and @ts-ignore where necessary), you can even get the compiler to stop complaining! TypeScript does have some differences beyo…
TypeScript support added to Create React App
81–90 of 90 posts
Re: TypeScript support added to Create React App
#82Earlier quoted context omitted.
I'd call that a good thing, really. Not needing ever more dependencies. I think this is a solid direction to go. Let's just say I give the React devs... props.
Funny, cause just using typescript to compile means you get to drop a lot of Babel dependencies / eslint dependencies.
Re: TypeScript support added to Create React App
#83I'd love to use TypeScript, but I've hit walls of errors that are nearly as bad as the old C++ template errors! (Though to be fair, this was a while ago, the compiler may have improved). SO: Any good way to learn TypeScript, particularly the more complicated types?
What sort of errors are you running into, and what project setup are you using? If you're using Create-React-App-TS, that's a separate fork of CRA 1.x that adds TS support, and has _horribly_ restrictive lint rules (many common style practices are treated as _compile_ errors). See https://github.com/wmonk/create-react-app-typescript/issues/... for discussion. (I ran across this while trying to set up a TS project for…
Re: TypeScript support added to Create React App
#84Earlier quoted context omitted.
"Irresponsible" is a bit of an overstatement, don't you think? The TS team explicitly says their goal is to generate readable JS, unlike (for example) Clojure or Scala. Also, the async/await thing isn't an issue if you target the latest ECMAScript version. That's the only really ugly thing, and it's been easily avoidable for over a year.
Readable JS doesn't mean, convert back to the file in the format you used to for editing. That comment could make people throw away the original and end up with machine generated code when going back.
I used to have a problem where I'd be debugging the JS instead of TS file because visually, they were almost identical.
Re: TypeScript support added to Create React App
#85Earlier quoted context omitted.
What sort of errors are you running into, and what project setup are you using? If you're using Create-React-App-TS, that's a separate fork of CRA 1.x that adds TS support, and has _horribly_ restrictive lint rules (many common style practices are treated as _compile_ errors). See https://github.com/wmonk/create-react-app-typescript/issues/... for discussion. (I ran across this while trying to set up a TS project for…
I use TypeScript every day, and I like it way better than JavaScript, but here is an example of a bad error message: http://ss.nican.net/photo_2018-10-22_22-09-58.jpg
In that _specific_ example, I think the key part is the "... is not assignable to ServerRoute | ServerRoute[]". It's just giving you all the fields in the type of the object you _are_ returning, and trying to tell you "I can't go from an A to a B". But yes, hard to pick out the key bits of info in there.
Re: TypeScript support added to Create React App
#86I'd love to use TypeScript, but I've hit walls of errors that are nearly as bad as the old C++ template errors! (Though to be fair, this was a while ago, the compiler may have improved). SO: Any good way to learn TypeScript, particularly the more complicated types?
I ask because you say that you want to learn the more complicated types, but I'd say it is better to stick to the basic types for your own code.
It seems obvious to me now, but It took me a while to realize: the reason TS type system is so advanced is to be able to accommodate all the crazy JavaScript APIs that are already out there in the real world. New code doesn't need (and most likely should not) use many of those complicated patterns.
This is also why other compile-to-JS languages have an advantage over TS: they don't have the burden of having to express all the craziness that is JS, and will probably be built around a much simpler/cohesive core of ideas.
TS is still an amazing compiler that provides lots of value: many projects other than TS benefit from TS type definitions. But I'd rather use something else if I'm writing an app from scratch. I'm exploring ClojureScript these days.
Re: TypeScript support added to Create React App
#87Pretty much just file extension support and docs. The support mainly comes from Babel 7.
Re: TypeScript support added to Create React App
#88Re: TypeScript support added to Create React App
#89This is awesome. I recently moved from Typescript to plain Javascript for a project and it is quite frustrating. You don't realise what you had till it's gone!
For someone stubborn that refuse to use TS, what are you missing ? Is it the IDE tools or the compiler error messages, or writing type annotations ?
Re: TypeScript support added to Create React App
#90Earlier quoted context omitted.
Funny, cause just using typescript to compile means you get to drop a lot of Babel dependencies / eslint dependencies.
There's still react-scripts-ts [1] which drops the majority of Babel in the CRA pipeline for solely Typescript. Presumably, it will remain active as it is still a useful alternative if you know you are going to want Typescript from day one. (This Babel-based support is perfect for those unsure and looking to experiment, which is great.) [1] https://github.com/wmonk/create-react-app-typescript
https://github.com/wmonk/create-react-app-typescript/issues/...