【发布时间】:2017-04-28 03:28:15
【问题描述】:
在 typescript 中,这段代码是有效的并且可以编译,但我不明白为什么:
const a: any = "Not void";
const x: void = a;
为什么允许这样做?文档说 void 与 any 相反,因此将 any 分配给 void 对我来说似乎是一个错误 (https://www.typescriptlang.org/docs/handbook/basic-types.html)
【问题讨论】:
标签: typescript