打字稿:确保对象具有某些属性

时间:2019-08-13 10:27:27

标签: typescript

让我说我有一个功能

doSomething(param: ???) {
    param.test
}

如何确保param是具有test作为属性之一的字符串的对象?

const myParam = { test: '123', ... }

0 个答案:

没有答案