Earlier quoted context omitted.
The problem IMHO is the old adage of the devil being in the details. I see a lot of engineers talking about things like deriving types from enums, and meanwhile the type system will merrily let you do this: type Foo = {a: number} const o: Foo = JSON.parse('null') o.a = 1 It feels like people are lulling themselves into a false sense of security by making increasingly complex self-consistence schemes via type utilitie…
I've run into issues with TypeScript that forced me to cast string literal types to themselves before it would compile. So literally this code: 'x' as 'x' Nothing else would work, we were simply forced to do that. Avoiding `any` in all cases is simply not possible, as Redux will require you to use it at least once as of the last time I used TypeScript, which wasn't that long ago. Type discoverability for libraries wa…
Using TypeScript with React
91–100 of 195 posts
Re: Using TypeScript with React
#92Earlier quoted context omitted.
> now throws ~30 errors on build Yep, it's a beautiful technology, total type safe heaven. Two basic basic rules if you want to work with TS: 1: apply the 'any' type 2: tweak TSC config so it won't complain anymore All companies I worked for in the past few years that use TS did this to keep TS 'out of the way'. And with that you completely annihilate the main benefit of using TS! I think it's hilarious and sad at th…
>> Two basic basic rules if you want to work with TS: 1: apply the 'any' type 2: tweak TSC config so it won't complain anymore That should be at the top of every page on the TypeScript documentation website. It would save developers so much suffering. >> All companies I worked for in the past few years that use TS did this to keep TS 'out of the way'. And with that you completely annihilate the main benefit of using…
I don't have this experience at all in other strongly typed languages, including very strong ones like Haskell/PureScript. The types there just work for me.
Re: Using TypeScript with React
#93I've been writing Typescript with React for quite a while now and these are my feelings so far: - Typescript type system is pretty awesome, and allows the expression of some things really elegantly; in particular, string literal types are quite cool for component props that feel "htmly", union and intersection types are great for making reusable/generic components and Partial is cool for making typesafe component sta…
FWIW I have a used-in-production project that generates idiomatic TypeScript types for protobuf:
https://github.com/stephenh/ts-proto
As a disclaimer, it assumes you use Twirp for any RPC impls, merely b/c that is what we used, and so it needs a config flag to turn that off + also eventual support for canonical GRPC-style RPC.
And also the docs/install/setup all need polished, but feel free to file issues / PRs if you try it.
Re: Using TypeScript with React
#94Earlier quoted context omitted.
I am a backed developer 90% of the time, but I currently have to work on a Typescript / React application that an agency did for us - cleaning up the bugs. Is there a good resource to demonstrate how to get around the problems you get with typing? At the moment I am using @ts-ignore to get things done. (Saying "you are probably doing it wrong" isn't really very helpful).
https://github.com/piotrwitek/react-redux-typescript-guide This is a good list of how to use common React patterns in Typescript.
Re: Using TypeScript with React
#95Earlier quoted context omitted.
I am a backed developer 90% of the time, but I currently have to work on a Typescript / React application that an agency did for us - cleaning up the bugs. Is there a good resource to demonstrate how to get around the problems you get with typing? At the moment I am using @ts-ignore to get things done. (Saying "you are probably doing it wrong" isn't really very helpful).
Could you give an example of the kind of problem you're talking about?
Re: Using TypeScript with React
#96Earlier quoted context omitted.
>If it's tedious, you're probably doing something wrong or sub-optimal. >IMHO we're reaching the point where typescript (or similar languages) should be used by default over untyped javascript in professional environments. It's like having tests, which are also not generally considered optional. Gotta love JS community. It flip-flops on some major aspect of system design roughly every year, yet people continue to arr…
The problem IMHO is the old adage of the devil being in the details. I see a lot of engineers talking about things like deriving types from enums, and meanwhile the type system will merrily let you do this: type Foo = {a: number} const o: Foo = JSON.parse('null') o.a = 1 It feels like people are lulling themselves into a false sense of security by making increasingly complex self-consistence schemes via type utilitie…
Typescript is one of the rare good things in javascript. You have to understands JS, because there is always gun pointed at your foot, waiting to blow you away. Still TS makes this gun, a little bit harder to trigger. You cannot just write Java in it and cross your fingers.
Typescript gives you pretty good docs most of the time for free. Only problem is when author of code used `any` type or `Angry Lisp` version of it. Interfaces, enums and field access and typedefs are godsend.
In defense of TypeScript, your example looks like casting `void*` in C. Well typed `JSON.parse` would be pretty complicated and require runtime-machinery.
Only thing I dislike about TS is lack of proper `optional` types. I know the '.?' operator is coming, but still.
Re: Using TypeScript with React
#97Earlier quoted context omitted.
I guess people in the React community are already used to massive dependency bloat, constantly failing vulnerability reports, library version incompatibility, huge install times, huge compile times, source mapping issues, dependency issues and build + linking issues across various environments so I guess TypeScript doesn't add much additional pain. But what if I told you that it's possible to build cleaner, more stab…
I'm listening...
Re: Using TypeScript with React
#98The creator of it answers “why typescript” in a video[1] with a hilarious answer which includes his observation that large javascript codebases become read only :-D
I’m giving a talk on typescript Friday. Some good stuff to understand is index signatures for object lookups, union types, intersection types, combining index signatures with named properties, and compile time immutability with readonly, Readonly, ReadonlyArray, ReadonlyMap.
The language is so much fun to both write and read. There’s a lot of depth to it as well. Excited to get to use it.
Re: Using TypeScript with React
#99Typescript is a lot easier to deal with if you stop treating it as optional and do it from day 1. Avoid using the any type and things fall in to place. If it's tedious, you're probably doing something wrong or sub-optimal. Or you're just dealing with a bit of hairy old javascript that probably needs a bit of refactoring in any case. IMHO we're reaching the point where typescript (or similar languages) should be used…
Re: Using TypeScript with React
#100Earlier quoted context omitted.
>> Two basic basic rules if you want to work with TS: 1: apply the 'any' type 2: tweak TSC config so it won't complain anymore That should be at the top of every page on the TypeScript documentation website. It would save developers so much suffering. >> All companies I worked for in the past few years that use TS did this to keep TS 'out of the way'. And with that you completely annihilate the main benefit of using…
I do find it rather strange that strongly typed code with no errors, that builds correctly, can fail at runtime due to type errors. My JS oftentimes ends up nicer than my TS because I don't have pages of, basically, type-level administrative work. I don't have this experience at all in other strongly typed languages, including very strong ones like Haskell/PureScript. The types there just work for me.