Syntax error when generic type parameter contains `=`
auvred opened this issue · comments
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?
- vue-eslint-parser@9.4.2
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')})"