Re:All I Want for Christmas Is These Seven TypeScript Improv...
by goto11 on Monday December 26, 2022 @08:31AM
(#34137458)
Doesn't fit with the Typescript philosophy though: It should be possible to gradually add Typecript annotations to existing JavaScript code. It wouldn't work with 3rd party libraries either.
[ Parent
| on HN ]
Re:All I Want for Christmas Is These Seven TypeScript Improv...
by Waterluvian on Monday December 26, 2022 @09:55AM
(#34138042)
I agree that it’s not practical. Ship has sailed a long time ago.
But one solution might be a “noImplicitImpure” option.
Re:All I Want for Christmas Is These Seven TypeScript Improv...
by goto11 on Monday December 26, 2022 @11:08AM
(#34138814)
Still wouldn't work, since there is no way for the compiler to distinguish between a pure function and an impure function which just don't have an annotation - e.g. a third-party library written before "impure" was introduced to the language.
If pure functions were explicitly marked as "pure" the compiler could just conservatively assume all other functions were impure. But the opposite does not work.
Re:All I Want for Christmas Is These Seven TypeScript Improv...
by Waterluvian on Monday December 26, 2022 @01:19PM
(#34140232)
Oh. You’re right. The moment you turn that flag on, it can’t complain the away implicitAny can. Therefore you need “pure” rather than “impure.”