Skip to content
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

Merged
merged 4 commits into from
May 30, 2021
Merged

fix: add missing @types/estree #214

merged 4 commits into from
May 30, 2021

Conversation

styfle
Copy link
Member

@styfle styfle commented May 25, 2021

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.

@styfle styfle requested a review from guybedford May 25, 2021 00:32
@styfle styfle requested review from lucleray and Timer as code owners May 25, 2021 00:32
@shortcut-integration
Copy link

This pull request has been linked to Clubhouse Story #22161: Add better TS types to @vercel/nft.

@guybedford
Copy link
Contributor

Nice work, let me know if you want help getting this over the line.

src/utils/wrappers.ts Outdated Show resolved Hide resolved
src/utils/wrappers.ts Outdated Show resolved Hide resolved
src/utils/wrappers.ts Outdated Show resolved Hide resolved
src/utils/wrappers.ts Outdated Show resolved Hide resolved
src/utils/wrappers.ts Outdated Show resolved Hide resolved
@guybedford
Copy link
Contributor

I've pushed up the type fixes here - CI should be passing now.

@codecov
Copy link

codecov bot commented May 29, 2021

Codecov Report

Merging #214 (7dfe439) into main (d4dc1ce) will decrease coverage by 0.01%.
The diff coverage is 79.68%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
src/utils/wrappers.ts 74.75% <78.72%> (+1.07%) ⬆️
src/utils/special-cases.ts 88.60% <80.00%> (-0.15%) ⬇️
src/analyze.ts 87.52% <85.71%> (-0.19%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d4dc1ce...7dfe439. Read the comment docs.

walk((m.body as unknown) as ESNode, {
enter (_node, _maybeParent) {
const node = _node as Node;
const maybeParent = _maybeParent as Node | undefined;
Copy link
Member Author

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.

Copy link
Contributor

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.

Copy link
Member Author

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?

Copy link
Contributor

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.

@styfle styfle merged commit 2b97d7d into main May 30, 2021
@styfle styfle deleted the ch22161/ts-types branch May 30, 2021 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants