命名空间'“ /app/src/redux/const".REDUX'没有导出的成员'ACTIONS'TS2694

时间:2019-12-09 22:35:32

标签: reactjs redux namespaces export const

我想知道为什么这段代码不起作用

// file: /app/src/redux/const.ts
export namespace REDUX {
    // Expected this to be public
    export type LoginIdentity = string;
    export type LoginPassword = string | null;

    // Expected this to by private
    const ACTION_TYPES = {
        ACTION_TYPE_LOGIN: 'ACTION_TYPE_LOGIN'
    };

    // Expected this to be public
    export const ACTIONS = {
        LOGIN: {
            type: ACTION_TYPES.ACTION_TYPE_LOGIN,
            payload: {
                identity: typeof LoginIdentity,
                password: typeof LoginPassword
            }
        }
    };
}

这是我的用法

// file: /app/src/redux/actions/login.ts
import { REDUX } from '../const';

export default function login(identity: REDUX.LoginIdentity, password: REDUX.LoginPassword) : REDUX.ACTIONS.LOGIN {
    return {
        type: REDUX.ACTION_TYPES.ACTION_TYPE_LOGIN,
        payload: {
            identity: identity,
            password: password
        }
    }
}

TSC以某种方式向我显示了未导出REDUX.ACTIONS的错误,但是ACTIONS定义包含export关键字,所以我不知道问题出在哪里。

0 个答案:

没有答案