我目前正在尝试获取打字稿编译器(该脚本用于jsDoc的javascript代码)以识别全局范围内的范围变量。 根据{{3}}的jsDoc文档,这就是它的工作方式。但是打字稿编译器仍然在编辑器中引发错误
(function () {
/** @global */
var foo = 'hello foo';
this.foo = foo;
}).apply(window);
let t = foo; // throws error cannot find name 'foo'
tsconfig.json:
"allowJs": true,
"checkJs": true,
"target": "esnext",
"typeRoots": [
"node_modules/@types",
"customTypes/*"
],
"outDir": "compiledjs/shutup",
"lib": [
"dom",
"esnext"
]