types
の定数の参照方法は?例えば、私は、AとBのような定数値を下回る有しとして(私は後でtypescriptを使用して定数の型を定義する方法は?
const PATH = '@@test/';
export const A = `${PATH}A`;
export const B = `${PATH}B`;
export type Action =
// UI actions
{ type: typeof A, payload: { a: any } }
| { type: B, payload: { b: boolean }}
//使用
const id = (state= initialState, action: Action) => {
const nextState = state;
switch (action.type) {
case A: {
const{a} = action.payload;
break;
}
case B: {
const { b} = action.payload;
break;
}
default:
break;
}