kaleidawave / ezno

A JavaScript compiler and TypeScript checker written in Rust with a focus on static analysis and runtime performance
https://kaleidawave.github.io/posts/introducing-ezno/
MIT License
2.3k stars 42 forks source link

`console.log` not variadic #133

Closed CharlesTaylor7 closed 2 months ago

CharlesTaylor7 commented 2 months ago

Checking

console.log("a", "b")

Yields an excess argument error.

But, console.log() is variadic though, so I would want this to work.


I'd be happy to work on this, but I'm not sure how builtin function declarations are handled.

kaleidawave commented 2 months ago

Hey, that is correct and a bug!

Rest parameters / variadic functions and calling them has been implemented / is currently supported

You can see the calling implementation here https://github.com/kaleidawave/ezno/blob/24e35b98da5a6c705be3cce7eb56dc17bfcb32a4/checker/src/types/calling.rs#L1141


The issue is currently because Console is typed incorrectly: https://github.com/kaleidawave/ezno/blob/24e35b98da5a6c705be3cce7eb56dc17bfcb32a4/checker/definitions/overrides.d.ts#L167-L172

I think console.log was one of the first functions I added checking for and it was only a while later I added variadic functions. And thus I must have missed updating the definition

This is similar to #118 issue (which I left a comment on the status of reusing TypeScripts lib.d.ts definition). I have opened #121 which describes how I want to implement it (although it is not quite ready / waiting on some other things).

Unsure whether I should start doing #121 manually or wait for more checking features to be implemented 🤷‍♂️

kaleidawave commented 2 months ago

This specific issue is fixed in #135

image

Of course hopefully #121 should wipe out this category of built in mismatches