[HN Gopher] Show HN: ESInfer - Make JavaScript Type-Safe ___________________________________________________________________ Show HN: ESInfer - Make JavaScript Type-Safe Hello, folks. I'm Jiang, the author of ESInfer. I love writing Javascript because it has a prosperous ecosystem and is quick to get my hands dirty. However, sometimes it's painful when the flow is not fast to follow due to the lack of a type system. To solve this, I wrote ESInfer, a statical inference tool, to automatically type check and generate type annotations for Javascript. It works with pure Javascript without any add-ons to the language or user- space code and supports highly dynamic features, such as the modification of prototypes. It is still in the very early stage, which offers almost all ES5 features and a select set of ES6 features like array/object destructing. I'm working hard to bring all ES6+ features into it incrementally. If you heavily use javascript/typescript and do NOT want to write the type annotation sh*ts anymore, give it a try :) Author : jiangmy Score : 31 points Date : 2022-10-15 12:03 UTC (10 hours ago) (HTM) web link (esinfer.com) (TXT) w3m dump (esinfer.com) | activitypea wrote: | This looks really interesting! How is it different from just | running flowtype over plain js? | wolfgang42 wrote: | The website seems like it needs an explanation of what this is | for and when you'd want to use it; right now it leaves quite a | lot to the imagination. (Also, the GitHub link in the corner (a) | requires JavaScript for some reason instead of just being a | normal link, and (b) goes to an empty repo so it doesn't seem to | be possible to use this thing.) | | A big part of my confusion, I think, is that I'm not sure why | you'd _want_ to write code without type annotations. I can see a | use for autogenerating them from code that doesn't have any, but | the first example on the page infers the return type of hello() | as "t547061|string" which is rather more opaque than I'd prefer | from a diagnostic. A big part of why I use TypeScript is | _because_ of the type annotations: both so future readers can | understand my intent, and also to give the type checker hints | about what I was thinking so it can point to exactly where I went | wrong instead of going "this over here doesn't work with that | thing over there, I dunno, there's probably something in the | middle that's not right." So I'm curious what your thoughts are | on why you dislike annotations and how to make type errors clear | without leaning on them for support. | LASR wrote: | So this is a way to generate type annotations for you from JS? | The application must be to generate typescript as an example? | | I would encourage you to add some reasoning to your site. | [deleted] ___________________________________________________________________ (page generated 2022-10-15 23:00 UTC)