Subscribe on changes!

use script setup alongside export default will got compile error when exporting types

avatar
Nov 8th 2021

Version

3.2.21

Reproduction link

sfc.vuejs.org/

Steps to reproduce

Use as guide: https://github.com/vuejs/rfcs/blob/master/active-rfcs/0040-script-setup.md#usage-alongside-normal-script

This works (only export variable).

This breaks (export type and reference it in the script setup).

What is expected?

No compile error

What is actually happening?

Got compile error like this:

[plugin:vite:vue] Transform failed with 1 error:
/Users/upupming/projects/vue3-compact-template/src/components/Demo.vue:16:27: error: Expected ";" but found "++"
/Users/upupming/projects/vue3-compact-template/src/components/Demo.vue:16:27
Expected ";" but found "++"
14 |    expose()
15 |  
16 |  const props = __props as ue++
   |                             ^
17 |  }
18 |
    at failureErrorWithLog (/Users/upupming/projects/vue3-compact-template/node_modules/.pnpm/esbuild@0.13.12/node_modules/esbuild/lib/main.js:1493:15)
    at /Users/upupming/projects/vue3-compact-template/node_modules/.pnpm/esbuild@0.13.12/node_modules/esbuild/lib/main.js:1282:29
    at /Users/upupming/projects/vue3-compact-template/node_modules/.pnpm/esbuild@0.13.12/node_modules/esbuild/lib/main.js:629:9
    at handleIncomingPacket (/Users/upupming/projects/vue3-compact-template/node_modules/.pnpm/esbuild@0.13.12/node_modules/esbuild/lib/main.js:726:9)
    at Socket.readFromStdout (/Users/upupming/projects/vue3-compact-template/node_modules/.pnpm/esbuild@0.13.12/node_modules/esbuild/lib/main.js:596:7)
    at Socket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:290:12)
    at readableAddChunk (internal/streams/readable.js:265:9)
    at Socket.Readable.push (internal/streams/readable.js:204:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23

But volar static type checking is okay with no error:

image