Module has no exported member Vue Ts

Viewed 1725

I'm trying to import my own types inside my component, and something weird it's happening. So if I do :

Types

export type Size = 'foo' |'foo' | 'foo' | 'foo';
export type Type = 'foo' | 'foo' | 'foo' | 'foo';
export type State = 'foo'

Component

    import { Size, State, Type } from '@/typings/button-type';
    
    props: {
            size: {
                default: 'foo',
                type: String as PropType<Size>
            },
            state: {
                default: 'foo',
                type: String as PropType<State>
            },
            type: {
                default: 'foo',
                type: String as PropType<Type>
            }
        },

This works just fine. But now that I wanted to add the type Color, or just put all the types inside a button type that I want to create and use them; I'm getting an error. I don't know why it works with those 3 types and not the others.

Types Failed

    export type MyOwnType = {
        color: Color;
        size: Size;
        type: Type;
        state: State;
    }

type Color = 'foo' | 'foo';
type Size = 'foo' |'foo' | 'foo' | 'foo';
type Type = 'foo' | 'foo' | 'foo' | 'foo';
type State = 'foo'

export type Color = 'foo' | 'foo';
export type Size = 'foo' |'foo' | 'foo' | 'foo';
export type Type = 'foo' | 'foo' | 'foo' | 'foo';
export type State = 'foo'

And the I try to do:

            color: {
                default: 'foo',
                type: String as PropType<Color>
            }

or the same with the Object like PropType<MyOwnType['size']> I get the same error

Error


src/components/Btn/Btn.vue:11:14
TS2305: Module '"../../typings/button-type"' has no exported member 'Color'.
     9 |     import { defineComponent, computed, PropType } from '@vue/runtime-core';
    10 |     import { useI18n } from 'vue-i18n';
  > 11 |     import { Color, Size, State, Type } from '@/typings/button-type';
       |              ^^^^^

Either Color, or MyOwnType or Foo... has no exported member.

Any idea?

0 Answers
Related