-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add missing @types/estree #214
Conversation
This pull request has been linked to Clubhouse Story #22161: Add better TS types to |
Nice work, let me know if you want help getting this over the line. |
I've pushed up the type fixes here - CI should be passing now. |
Codecov Report
@@ Coverage Diff @@
## main #214 +/- ##
==========================================
- Coverage 80.19% 80.18% -0.02%
==========================================
Files 13 13
Lines 1404 1413 +9
Branches 538 535 -3
==========================================
+ Hits 1126 1133 +7
Misses 109 109
- Partials 169 171 +2
Continue to review full report at Codecov.
|
walk((m.body as unknown) as ESNode, { | ||
enter (_node, _maybeParent) { | ||
const node = _node as Node; | ||
const maybeParent = _maybeParent as Node | undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@guybedford What are your thoughts here? I'm pretty sure this is supposed to be a Node
not ESNode
and its surfacing a couple bugs below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The walk
function here uses a different Node
base type that has the start
and end
requirements as well. Typing this function properly is thus difficult due to the compat differences - can't use the base typing library you need to use another one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m not so much interested in the walk function but the enter handler. Can you talk a look at my most recent commit here to see how to resolve the error below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, I've pushed up a fix.
We've had several null/undefined bugs (such as #212) that can be avoided with better TS types.
This PR adds
@types/estree
as suggested by @sokra a few years ago and this seems to do the trick.