type AccountID = number
type Money = number
interface Request {
accountID: AccountID,
money: Money,
}
declare let r: Request
function testString(i: number) {}
function testAccountID(id: AccountID) {}
function testMoney(money: Money) {}
testString(r.accountID)
testString(r.money)
testAccountID(r.accountID)
testAccountID(r.money) // 希望报错
testMoney(r.accountID) // 希望报错
testMoney(r.money)
https://github.com/microsoft/...
现阶段不支持这种用法,issue 已经是很多年前的了,目前看来以后不支持的可能性也更高。