Subscribe on changes!

<script setup> can not work with import types from other .ts file

avatar
May 24th 2021

Version

3.1.0-beta.3

Reproduction link

https://github.com/DefectingCat/vue-setup-test/blob/a84784ac7457fdd55a26576644161a33b45893a7/src/components/SetupChild.vue#L8

Steps to reproduce

  1. in <script setup> use import to import some types like: import { StateType } from './types.ts;
  2. got an error from typescipt: 'StateType' only refers to a type, but is being used as a value here.ts(2693)

What is expected?

import a type, used as a type

What is actually happening?

tsc thinks <script setup> use it as a value


version:

  • "typescript": "~4.1.5"
  • "vue": "^3.0.0"

image

avatar
May 24th 2021

import type { State } from './types'

avatar
May 24th 2021

import type { State } from './types'

it works, thank you