Subscribe on changes!

SFC compiler doesn't support TS 4.5 import { type X }

avatar
Nov 18th 2021

Version

3.2.22

Reproduction link

sfc.vuejs.org/

Steps to reproduce

With TS 4.5

<script setup type=ts>
import { type Ref } from "vue"
</script>

What is expected?

Compiles

What is actually happening?

Compilation error: Unexpected token, expected ","


https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#type-on-import-names

avatar
Nov 18th 2021

Until this is supported, use import type { Ref } from 'vue'

avatar
Nov 18th 2021

@babel/parser supports this new syntax since 7.16, our lockfile has it locked at 7.15.8 right now. Hopefully bumping this dep is all it takes?

avatar
Sep 6th 2022

Until this is supported, use import type { Ref } from 'vue'

I have problems with that syntax too Screen Shot 2022-09-05 at 23 34 15

UPDATE

I solve it using lang="ts" on the script setup instead of type="ts"

<script setup lang="ts">
avatar
May 29th 2023

Supported now.