标签: javascript typescript types
就像有接口一样
interface IHello { x: 'hello'; } function fun(obj: IHello) { ... }
然后执行
var obj = { x: 'hello' }; fun(obj);
出现错误 类型string不能分配给类型hello;
string
hello
正确的做法是什么?