TyrealHu / acorn-typescript

Alternative, TypeScript parser
https://www.npmjs.com/package/acorn-typescript?activeTab=readme
MIT License
145 stars 18 forks source link

fix: `eatContextual` method and reduce keywords #18

Closed ota-meshi closed 1 year ago

ota-meshi commented 1 year ago

This PR fixes the eatContextual method to reduce unnecessary overriding keywords.

I noticed that the eatContextual method is not working properly. This PR fixes it.

      eatContextual(name: string) {
        if (keywordsRegExp.test(name)) {
          if (this.ts_isContextual(tokTypes[name])) {
            this.next()
            return true
          }
          return false
        } else {

-          super.eatContextual(name)
+          return super.eatContextual(name)
        }
      }

Also, by correcting the eatContextual method, I was able to reduce the overriding keywords, and in doing so I was able to remove the isContextual method from the override. This PR does that too.

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 57.14% and project coverage change: -0.06 :warning:

Comparison is base (6f0f1ae) 62.56% compared to head (d280912) 62.50%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #18 +/- ## ========================================== - Coverage 62.56% 62.50% -0.06% ========================================== Files 1 1 Lines 2941 2923 -18 Branches 967 959 -8 ========================================== - Hits 1840 1827 -13 + Misses 1094 1089 -5 Partials 7 7 ``` | [Impacted Files](https://app.codecov.io/gh/TyrealHu/acorn-typescript/pull/18?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tyreal+Hu) | Coverage Δ | | |---|---|---| | [src/index.ts](https://app.codecov.io/gh/TyrealHu/acorn-typescript/pull/18?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Tyreal+Hu#diff-c3JjL2luZGV4LnRz) | `62.50% <57.14%> (-0.06%)` | :arrow_down: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

ota-meshi commented 1 year ago

I now realize that, this change fixes the bug without having to merge #17. Because async is no longer a keyword.