Skip to content

@typescript-eslint/restrict-template-expressions reported in TS file due to imported type declared in a Vue component #216

@TNGD-YQ

Description

@TNGD-YQ

Problem

A type exported from a Vue component can be identified by VSCode properlym, but type aware linter complaints about it.

Image

Reproduce Steps

  1. Create a new project refer to https://vuejs.org/guide/quick-start#creating-a-vue-application.
  2. In the eslint.config.ts, change vueTsConfigs.recommended to vueTsConfigs.strictTypeChecked
  3. In the App.vue, export a type.
<script setup lang="ts">
export interface Item {
  value: string
  num: number
}
</script>
  1. Create a file test.ts.
import type { Item } from '@/App.vue'

const a: Item = { value: 'test', num: 123 }

const str = `This is a template string: ${a.value} and the number is: ${a.num}`

Expectation

Item.value is a string, so in TS file should not complainst about any type cannot be used in template literal expression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions