0
在TypeScript 2.0中引入了標記的工會。要使用它們我們就來介紹在接口判別屬性,例如:使用文字類型標記的工會和標記
interface Action {
type: "ACTION"
}
但是我不能使用字符串字面類型的判別:
let actionName: "ACTION"
interface Action {
type: actionName <- error: cannot find name "actionName"
}
我想知道如果這是一個功能或錯誤。