我想在我的打字稿代码中声明名为name的新变量。我只有一行代码。为什么我得到错误无法在TypeScript中重新声明块范围变量'name'
var name:string = "John";
但遇到错误
PS D:\TypeScript> tsc test.ts
C:/Users/Users/AppData/Roaming/npm/node_modules/typescript/lib/lib.d.ts(18568,15): error TS2451: Cannot re
declare block-scoped variable 'name'.
test.ts(1,5): error TS2451: Cannot redeclare block-scoped variable 'name'.
这是什么错误背后的原因是什么?
出现此错误的原因是全局范围中已存在变量'name'。 – Adelin