我试图在我的 typescript 模块中访问function.arguments
,但收到错误:
“参数”属性可能无法在严格模式函数上访问
即使 'use strict'
不存在于编译的文件中。
这是我的 tsconfig.json 设置:
"noImplicitUseStrict": true,
"alwaysStrict": false,
"strict": true,
如果我删除 "noImplicitUseStrict": true
编译的文件将具有 use strict
因此该设置在 typescript 端工作(可能?)。
搜索我编译的文件,我找不到包含“strict”一词的单个文件。
我使用node编译js文件:node src/index.js
最佳答案
ES6 模块以严格模式执行。
来自 MDN Other differences between modules and standard scripts
Also, note that you might get different behavior from sections of script defined inside modules as opposed to in standard scripts. This is because modules use strict mode automatically.
关于javascript - 即使代码中不存在,也会强制使用 strict,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56484791/