Today, I'm trying to get function signatures for a...
# devlog-together
i
Today, I'm trying to get function signatures for all the std lib stuff in JS… at runtime. Current attempt is converting various d.ts files from the typescript package (like, say, es5.d.ts) into a JSON file with just the bits I need. If that fails, I might try parsing the official WebIDL files (that are used to generate these d.ts files — at least, the dom ones). If there's a much more obvious way to get this info, let me know. I basically just want something that, for a given function (eg: Array.prototype.splice), gives me some basic signature info (eg: 1-2 args with rest, first arg is called "index", optional second is called "delete", rest is "items"). If all else fails I'll just do .length on these functions, but I'd prefer to get names too.
Okay, we're in business. Add "typescript compiler" to the list of stuff going into Hest at runtime (along with "physics engine", "gradient descent", "back propagation", etc)
❤️ 2
Yes, I know the above doesn't show the signature info I'm interested in. I got that working separately, but didn't have a good way to screenshot it. 🤷
j
Some of the APIs are pretty easy to scrape from various documentary sources, but the completist version of this task is a real horror show 🙈
👍 1
b
Dunno how complete, but i see Chrome devtools offers argument tooltips as you type. Where does it get that info?
in any case TypeScript can tell you much more about arguments than just their names 👍
i
Yeah, I just need to prove out a rough idea. If it works, it'll be easy enough to add more hinting.
(Eg: Very tempted to add an LLM that can look at a function call and offer advice about usage. Or, say, answer questions like "what should the inputs to this function be if the output is X?" At runtime. In the tight main event loop.)
j
The most complete resources for JS are: https://github.com/tc39/ecma262 https://github.com/tc39/ecma262/blob/main/spec.html … but for ahem reasons, this doesn’t include things like
setTimeout
, which is in a separate spec from the HTML working group, &c, &c. The only reason I know where the weirdness lives is that I spent some time on it while building this ClojureScript dev tool: https://x.com/jackrusher/status/1521781858547249152