具有2个参数的打字稿打字功能

时间:2019-07-22 21:26:32

标签: typescript typescript-generics

给出:

const I18 = { EN: { M1: { A: 'Hi' } } };


(page: Keys, label:string ) => () => string | string

用法

const current = 'EN';
const T = (param1, param2) => I18[current][param1][param2];

console.log( T('M1','A') ) //  return 'hi'; 

如何为此编写def类型?我尝试过:

type Opts = keyof typeof I18;
type Keys = keyof typeof I18.EN;

因此,我可以轻松键入param1和当前变量;但是如何提供对param2的检查?

0 个答案:

没有答案