Subscribe on changes!

Can't use interface defined in `script` for `defineProps` in `script setup`

avatar
Jul 30th 2022

Vue version

3.2.37

Link to minimal reproduction

https://sfc.vuejs.org/#eNpdULtuwzAM/BVCS1ogsdHVUFx0a7duXbS4Dp0osB6g6DaAoX8vZRtFkE13FO94N6u3GKufCVWjdOrJRoax8+ejUZyMao23LgZimIFw2MMJB+vxk0JMkGGg4GAn2zvjAYzH2/LXekYauh7hg9HBXIaMN35tIDFZfzY+G6/r1U88BGzeCXmKDxf0wSeGuHge7y/QRb59en7UEjaOHaMgAH15ad9xHAN8BRpPuha88JGwnedNN2ddF6JI/a+rvVrTH1wXq2sKXlpa0phtIAc2a77CSREFG3Vhjqmp6zT0pdtrqgKda3lVNHm2DitM7vBN4TchibBRRUI6ySr/Aa/ojP8=

Steps to reproduce

Run the SFC Playground (in Chrome)

What is expected?

The exported interface can be used to define the props. As it is in the same file. Because the interface is also exported, it cannot be defined in script block.

What is actually happening?

It doesn't compile.

System Info

System:
    OS: Windows 10 10.0.19044
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
    Memory: 4.96 GB / 15.95 GB
  Binaries:
    Node: 14.17.0 - C:\Program Files\nodejs\node.EXE
    npm: 6.14.13 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 103.0.5060.134
    Edge: Spartan (44.19041.1266.0), Chromium (103.0.1264.77)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    vue: ^3.2.37 => 3.2.37

Any additional comments?

When i don't export the interface, a different error is thrown (in my local IDE):

Transform failed with 1 error:
C:/[...]/Component.vue:23:25: ERROR: Unexpected ">"
  Unexpected ">"
  21 |    expose();
  22 |  
  23 |  const props = __props as >()*/
     |                           ^
  24 |  
  25 |  

Could be duplicate to #4423

avatar
Aug 1st 2022

duplicate of #5830