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

Passing a seemingly empty type to defineProps with defineDefaults throws an error #20369

Closed
smares opened this issue Apr 18, 2023 · 1 comment

Comments

@smares
Copy link

smares commented Apr 18, 2023

Environment

  • Operating System: Linux
  • Node Version: v16.14.2
  • Nuxt Version: 3.4.1
  • Nitro Version: 2.3.3
  • Package Manager: npm@7.17.0
  • Builder: vite
  • User Config: -
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://stackblitz.com/edit/github-voetqy?file=components/VTest.vue

Describe the bug

Trying to define a component's properties using an empty interface that extends another interface fails using withDefaults(defineProps<Props>(), { ... }

Additional context

Could be an issue in vuejs/core since this and this exist, but it was fixed in Vue 3.2.42 (2022-11-09).

Logs

[plugin:vite:vue] Transform failed with 1 error:
/home/projects/github-voetqy/components/VTest.vue:10:26: ERROR: Unexpected "}"
/home/projects/github-voetqy/components/VTest.vue:10:26
Unexpected "}"
8  |    expose();
9  |  
10 |  const props = __props as  };
   |                            ^
11 |  
12 |
    at failureErrorWithLog (file:///home/projects/github-voetqy/node_modules/esbuild/lib/main.js:1626:15)
    at eval (file:///home/projects/github-voetqy/node_modules/esbuild/lib/main.js:827:29)
    at responseCallbacks.<computed> (file:///home/projects/github-voetqy/node_modules/esbuild/lib/main.js:687:9)
    at handleIncomingPacket (file:///home/projects/github-voetqy/node_modules/esbuild/lib/main.js:742:9)
    at Socket.readFromStdout (file:///home/projects/github-voetqy/node_modules/esbuild/lib/main.js:663:7)
    at EventEmitter.emit (https://githubvoetqy-0f5x.w-corp.staticblitz.com/blitz.c8358679.js:35:156830)
    at S.emit (https://githubvoetqy-0f5x.w-corp.staticblitz.com/blitz.c8358679.js:35:1539231)
    at addChunk (https://githubvoetqy-0f5x.w-corp.staticblitz.com/blitz.c8358679.js:35:727409)
    at readableAddChunk (https://githubvoetqy-0f5x.w-corp.staticblitz.com/blitz.c8358679.js:35:727113)
    at Readable.push (https://githubvoetqy-0f5x.w-corp.staticblitz.com/blitz.c8358679.js:35:727797
Click outside or fix the code to dismiss.
You can also disable this overlay by setting server.hmr.overlay to false in vite.config.js.
@smares
Copy link
Author

smares commented Apr 18, 2023

Closing this one, too. It's actually related to #20370. The interface ends up being empty because Vue 3.2 does not support importing types to use for props. Will be addressed in Vue 3.3.

@smares smares closed this as completed Apr 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant