enum LEVELS {
debug = 0,
warn,
error,
info,
}
export default interface ILogger {
[LEVELS[LEVELS.debug]]: ([prop]: any) => void;
[LEVELS[LEVELS.warn]]: Function;
[LEVELS[LEVELS.error]]: Function;
[LEVELS[LEVELS.info]]: Function;
}
class Logger implements ILogger {
debug(){}
warn(){}
error(){}
info(){}
}
写了一个enum 一个接口像上面这样,但是出现了错误
A computed property name in an interface must refer to an expression whose type is a literal type or a 'unique symbol' type.