Skip to content

Incorrect handling of importing types in script-setup #300

Closed
@roamiiing

Description

@roamiiing

App.vue:

<template>
  <div @click="count++">{{ count }}</div>
</template>

<script setup lang="ts">
import { ref, Ref } from 'vue';

const count: Ref<number> = ref(0);
</script>

I see that explicitly defining the Ref<number> type is not necessary, but this is just an example. VSCode shows an error in the import statement:

Screenshot 2021-07-13 at 19 34 06

Which is not actually an error because the imported type Ref is not being used as a value anywhere. This doesn't happen if we rewrite this code without using <script setup>:

<template>
  <div @click="count++">{{ count }}</div>
</template>

<script lang="ts">
import { defineComponent, ref, Ref } from 'vue';

export default defineComponent({
  setup() {
    const count: Ref<number> = ref(0);

    return {
      count,
    };
  },
});
</script>

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions