I'm shocked at how often I run into problems due to TypeScript's generous usage of `any` in the standard library definitions. `unknown` is much more appropriate. The promotion of escaping type safety in such a fundamental place is worrying.
-
Show this thread
-
Replying to @sebmck
Would love a config that converts all any to undefined, including any cases where TS would infer any to instead infer unknown.
3 replies 0 retweets 9 likes -
Replying to @leeb
Yesss. I have almost removed all usages of ts-ignore and any/Function/Object in my project. Discovering that the stdlib leaks unsoundness was a bummer.
3 replies 1 retweet 6 likes -
Adding downcasts don't produce soundness, it just shifts blame
1 reply 0 retweets 0 likes -
I'm not particularly well versed in proper type system terminology. Where there is any, it produces uncertainness in my code which is why I use a type system in the first place. With proper refinements dealing with unknown is easy and I would prefer extra validation code anyway.
1 reply 0 retweets 2 likes -
In practice that's really the exception. Most people call JSON.parse and perform ~zero runtime validation on it; they just want to tell the type system what the expected type is. That's equally unsound between 'any' vs downcasted 'unknown'
3 replies 0 retweets 1 like -
It's only the exception because it's hard to do without a validation library, deficiencies in TypeScript refinements, and there not being a strong culture for it
1 reply 0 retweets 0 likes -
[No one is doing this because no one wants to do it] seems like a self-defeating argument? The vast majority of JS code trusts the result of JSON.parse follows the schema the server said it would; very few devs want to ship client code to validate that the server isn't broken
5 replies 0 retweets 3 likes
What I'm saying is I want to do it, so I'm going to do it, and I will make it easier for others to do it, so more people do it, until hopefully everyone does it.
-
-
Cheering for you
0 replies 0 retweets 4 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
he/him 