前几天在书写TypeScript代码时,出现了声明变量报错的情况,具体情况如下:
TypeScript
let arr: number;
arr = 10;
console.log(arr);
报错如下:


解决方案:
在配置文件tsconfig.json中,配置如下代码:
TypeScript
{
"compilerOptions":{
"isolatedModules": true
}
}
如下图所示:
