DEV Community

Discussion on: Typescript: Are you over-typing your functions?

Collapse
 
joelbonetr profile image
JoelBonetR 🥇

I find it funny because the "maybe", "unknown" and all those types are getting more visibility this days in the community plus I saw many posts about generics and so...

For me it's like... Dude, you're tired of defining all that BS. I get it. I understand it. Just use JS, you'll be fine 😅

Thread Thread
 
syeo66 profile image
Red Ochsenbein (he/him)

Well, I do have to say that for one the Maybe monad is a thing I really like in functional programming. It's way better than having unhandled null values all over the place.

Also unknown is probably the best solution if you really don't know (or care) about a type. It forces the receiver of the type to actually test for the validity of a value (except of course the dev just resorts to as ... or worse @ts-ignore). And this is IMO the value of typescript: It forces you to think about what values you actually can expect and what possible error states you have to deal with.

But then, if you don't like using Typescript in strict mode, or tend to resort to the the easy way out (like any, as ... or @ts-ignore) you better don't use Typescript because it would only make things worse.

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇

Indeed