3 ms·
Is typescript strong typing though? I’ve been through several typescript projects where ‘as unknown as any’ makes me wish we didn’t even have typescript in the
by dartos 3y ago
Is typescript strong typing though?
I’ve been through several typescript projects where ‘as unknown as any’ makes me wish we didn’t even have typescript in the first place.
If you can’t trust the type system it’s worse than not having one :/
- agos 3y agoif you abuse the type system enough, most languages will have weaker typing. "the language" is not enough per se, you have to use the tools it gives you to gain some advantage: those projects were clearly actively avoiding strong typing, for whatever reason
- dartos 3y agoIn js land some packages don’t have strong types or, worse, wrong handmade types. ‘as unknown as any’ is kind of needed in those cases.
- jrajav 3y agoI, too, find tools hard to use after I intentionally break them. It's unfortunate that Typescript even provides this casting hack, though it's necessary for gradual, optional typing. The very first thing I would do on such a project is spend the time to fix those broken types, because it will pay back in full in productivity after a short time.
- Tade0 3y ago> Is typescript strong typing though? The term "strong typing" doesn't have a clear definition to begin with. Other terms which it often substitutes do, e.g. static typing, sound type system, decidable type system etc.
- ng12 3y agoYou can write bad code in any language.
- junon 3y agoI'm tired of this adage. Yes, you can. Some languages make it way, way easier to write bad code, though.
- master-lincoln 3y agoI think this comment doesn't add to the discussion. It's like saying you can kill yourself in any vehicle. Might be true (or maybe not), but doesn't add to the discussion of vehicle safety.
- poszlem 3y agoThis is a thought-terminating cliché and does not add anything to the discussion.
- darthrupert 3y agoAnd only poor drivers need seatbelts.
- master-lincoln 3y agoapparently the words strong and weak typing have no agreed upon definition so they can not be meaningfully discussed without stating your definition. e.g. https://perl.plover.com/yak/12views/samples/slide045.html https://perl.plover.com/yak/12views/samples/slide045.html
- rpdillon 3y agoWow, that's a fairly eye-opening post! I have always used definition 5 for strong typing. I would love to know where the other definitions come from.