Hacker News new | ask | show | jobs
by dartos 988 days 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 :/

5 comments

apparently 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

Wow, 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.
> 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.

I, 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.

if 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

In 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.
You can write bad code in any language.
I'm tired of this adage. Yes, you can. Some languages make it way, way easier to write bad code, though.
I 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.
This is a thought-terminating cliché and does not add anything to the discussion.
And only poor drivers need seatbelts.