Re:Ask HN: Why does front-end development change so often?
by ng12 on Sunday January 20, 2019 @03:10AM
(#18951851)
> Typescript's inability to handle libraries intended for the web
Can you elaborate? TypeScript is incredibly popular for client-side development.
Re:Ask HN: Why does front-end development change so often?
by furi on Sunday January 20, 2019 @03:21AM
(#18951896)
Maybe I missed something, but my experience was that Typescript was capable of making useful conclusions (i.e. MyLibrary.MyType.width exists, but MyLibrary.MyType.dog does not) about other libraries, delivered to it via NPM, that were also written in Typescript. If your libraries were written in JavaScript to be run in the browser you were stuck doing `declare var mylibrary: any;` and writing "unsafe" code. This is also true of any global variables/functions/etc. that exist in <script> tags in your HTML.
To be clear I don't expect it to be able to do this, reading JavaScript that was written without types and deciding what the types are sounds more or less impossible, it's just a demonstration of how you tend to end up with an imperfect solution as a result of the decisions made early on in the web's development.
This environment is simultaneously so restrictive (in that you can't really introduce new languages except by having them transpile to JavaScript) and so bad that people end up trying to tie it into something more cohesive (React's virtual DOM, Typescript) and then only partly succeeding (React's dependence on setState and things often being much easier to do with document.getElementById than in the React way, Typescript's inability to handle libraries intended for the web), leading other people to try do it better.