【发布时间】:2019-03-11 04:02:00
【问题描述】:
我正在关注quide,但我选择不禁用 TSLint 默认设置。但是也许我应该有,因为现在当我尝试分配 null(给任何类型)时它会给我一条错误消息:
function f()
{
const a :string = null; //Type 'null' is not assignable to type 'string'
return a;
}
f();
数字也一样。我的问题是为什么 TSLint 选择完全禁用此类构造。另外,如果我改为分配这样的空字符串,是否可以:
const a :string = "";
【问题讨论】:
标签: typescript tslint