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

Syntax error when generic type parameter contains = #233

Closed
3 of 4 tasks
auvred opened this issue May 13, 2024 · 0 comments · Fixed by #234
Closed
3 of 4 tasks

Syntax error when generic type parameter contains = #233

auvred opened this issue May 13, 2024 · 0 comments · Fixed by #234

Comments

@auvred
Copy link

auvred commented May 13, 2024

Before You File a Bug Report Please Confirm You Have Done The Following...

  • I'm using eslint-plugin-vue.
  • I'm sure the problem is a parser problem. (If you are not sure, search for the issue in eslint-plugin-vue repo and open the issue in eslint-plugin-vue repo if there is no solution.
  • I have tried restarting my IDE and the issue persists.
  • I have updated to the latest version of the packages.

What version of ESLint are you using?

n/a

What version of eslint-plugin-vue and vue-eslint-parser are you using?

What did you do?

<!-- app.vue -->
<script lang="ts" setup generic="T extends () => string">
</script>
// index.js
const { parse } = require('vue-eslint-parser')
parse(require('fs').readFileSync('./app.vue', 'utf-8'), { parser: require('@typescript-eslint/parser') })

What did you expect to happen?

Parse the Vue SFC with no errors.

What actually happened?

/.../node_modules/vue-eslint-parser/index.js:894
            throw perr;
            ^

SyntaxError: '=>' expected.
    at ParseError.normalize (/.../node_modules/vue-eslint-parser/index.js:98:20)
    at parseScriptFragmentWithOption (/.../node_modules/vue-eslint-parser/index.js:891:33)
    at parseScriptFragment (/.../node_modules/vue-eslint-parser/index.js:880:12)
    at parseScriptElement (/.../node_modules/vue-eslint-parser/index.js:1171:20)
    at parseAsSFC (/.../node_modules/vue-eslint-parser/index.js:6438:18)
    at parseForESLint (/.../node_modules/vue-eslint-parser/index.js:6398:53)
    at Object.parse (/.../node_modules/vue-eslint-parser/index.js:6406:12)
    at [eval]:1:30
    at runScriptInThisContext (node:internal/vm:209:10)
    at node:internal/process/execution:109:14 {
  code: undefined,
  index: 55,
  lineNumber: 1,
  column: 55
}

Link to Minimal Reproducible Example

mkdir repro
cd repro
echo '{"dependencies":{"@typescript-eslint/parser":"^7.8.0","vue-eslint-parser":"9.4.2"}}' > package.json
npm i
node -p "require('vue-eslint-parser').parse('<script lang=\"ts\" setup generic=\"T extends () => string\">\n</script>', {parser: require('@typescript-eslint/parser')})"

Additional comments

This issue seems to have appeared after #221 -> #222

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 a pull request may close this issue.

1 participant