模块没有导出成员 Vue Ts

Pau*_*l B 5 typescript vue.js vuejs3

我试图在我的组件中导入我自己的类型,但发生了一些奇怪的事情。所以如果我这样做:

类型

export type Size = 'foo' |'foo' | 'foo' | 'foo';
export type Type = 'foo' | 'foo' | 'foo' | 'foo';
export type State = 'foo'
Run Code Online (Sandbox Code Playgroud)

成分

    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>
            }
        },
Run Code Online (Sandbox Code Playgroud)

这很好用。但现在我想添加颜色类型,或者只是将所有类型放入我想要创建和使用它们的按钮类型中;我收到错误。我不知道为什么它适用于这 3 种类型而不适用于其他类型。

类型失败

    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'
Run Code Online (Sandbox Code Playgroud)

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

Run Code Online (Sandbox Code Playgroud)

我尝试做的:

            color: {
                default: 'foo',
                type: String as PropType<Color>
            }
Run Code Online (Sandbox Code Playgroud)

或与 PropType<MyOwnType['size']> 等对象相同我得到相同的错误

错误


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';
       |              ^^^^^

Run Code Online (Sandbox Code Playgroud)

Color、MyOwnType 或 Foo... 没有导出成员。

任何想法?