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

Destructured default value failed on named slots #12841

Closed
a161803398 opened this issue Oct 19, 2022 · 0 comments
Closed

Destructured default value failed on named slots #12841

a161803398 opened this issue Oct 19, 2022 · 0 comments

Comments

@a161803398
Copy link
Contributor

Version

2.7.13

Reproduction link

github.com

Steps to reproduce

  1. run npm i
  2. run npm run dev
  3. open dev url in browser

What is expected?

no error

What is actually happening?

After open dev url in browser given following error.

Invalid shorthand property initializer. (1:7)
[vite] Internal server error: Invalid shorthand property initializer. (1:7)
  Plugin: vite:vue2
  File: C:/Users/user/Desktop/v-slot-issue/src/App.vue
  1  |  <script setup lang="ts">
     |         ^
  2  |  import Test from './Test.vue'
  3  |  </script>
      at instantiate (C:\Users\user\Desktop\v-slot-issue\node_modules\@babel\parser\lib\index.js:72:32)
      at constructor (C:\Users\user\Desktop\v-slot-issue\node_modules\@babel\parser\lib\index.js:359:12)
      at Object.raise (C:\Users\user\Desktop\v-slot-issue\node_modules\@babel\parser\lib\index.js:3339:19)
      at Object.checkExpressionErrors (C:\Users\user\Desktop\v-slot-issue\node_modules\@babel\parser\lib\index.js:4083:12)
      at Object.parseMaybeAssign (C:\Users\user\Desktop\v-slot-issue\node_modules\@babel\parser\lib\index.js:12359:12)
      at Object.parseMaybeAssign (C:\Users\user\Desktop\v-slot-issue\node_modules\@babel\parser\lib\index.js:10730:20)
      at Object.parseExpressionBase (C:\Users\user\Desktop\v-slot-issue\node_modules\@babel\parser\lib\index.js:12257:23)
      at C:\Users\user\Desktop\v-slot-issue\node_modules\@babel\parser\lib\index.js:12251:39
      at Object.allowInAnd (C:\Users\user\Desktop\v-slot-issue\node_modules\@babel\parser\lib\index.js:14346:16)
      at Object.parseExpression (C:\Users\user\Desktop\v-slot-issue\node_modules\@babel\parser\lib\index.js:12251:17)

It looks like a similar issue as #12591 but on v-slot.

The issue seems to be solved by export slotRE and use it to set slot baseName in compileScript.ts.

          const baseName = onRE.test(name)
            ? 'on'
+           : slotRE.test(name)
+           ? 'slot'
            : bindRE.test(name)
            ? 'bind'
            : name.replace(dirRE, '')
a161803398 added a commit to a161803398/fix-named-v-slot that referenced this issue Oct 19, 2022
a161803398 added a commit to a161803398/fix-named-v-slot that referenced this issue Oct 19, 2022
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

No branches or pull requests

1 participant