Skip to content

Typescript: Eslint can't detect types exported from Vue SFC  #2375

Open
@jordan-erisman

Description

@jordan-erisman

Checklist

  • I have tried restarting my IDE and the issue persists.
  • I have read the FAQ and my problem is not listed.

Tell us about your environment

  • ESLint version: 8.56.0
  • **eslint-plugin-vue version:9.20.1
  • **Vue version:3.4.13
  • **Node version:18.18
  • **Operating System:OSX

Please show your full configuration:

module.exports = {
  ignorePatterns: ['tsconfig.json', '*.config.js', '*.config.ts'],
  extends: [
    'eslint:recommended',
    'plugin:vue/vue3-recommended',
    'plugin:@typescript-eslint/recommended',
    'plugin:@typescript-eslint/recommended-requiring-type-checking',
  ],
  plugins: ['@typescript-eslint'],
  parser: 'vue-eslint-parser',
  parserOptions: {
    parser: '@typescript-eslint/parser',
    project: ['tsconfig.json'],
    extraFileExtensions: ['.vue'],
  },
};

What did you do?

Reproduction link (StackBlitz). Run npm run lint

Child

<script lang="ts">
export type MyType = {
  test: string;
};
</script>

....

Parent

<script setup lang="ts">
import {type MyType} from './Child.vue';

// Unsafe assignment of an `any` value
const obj: MyType = { test: '123' };

// Unsafe member access .test on an `any` value
const test = obj.test;
</script>

What did you expect to happen?
The imported types to work. Typescript recognizes the type and does not complain, but eslint throws and error.

What actually happened?

  14:7   error  Unsafe assignment of an `any` value           @typescript-eslint/no-unsafe-assignment
  14:16  error  Unsafe member access .test on an `any` value  @typescript-eslint/no-unsafe-member-access

✖ 2 problems (2 errors, 0 warnings)

Repository to reproduce this issue

Reproduction link (StackBlitz). Run npm run lint

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions