2017-03-23 24 views
1

我正在关注Angular Tour of Heroes tutorialAngular:在Chrome的严格模式之外还不支持的块范围声明

我在加载应用程序localhost:3000时立即在Chrome浏览器(v47)中收到以下错误。相同的应用程序不会产生在Firefox错误(V45):

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode at eval (native) at SystemJSLoader.__exec (http://localhost:3000/node_modules/systemjs/dist/system.src.js:1555:18) at entry.execute (http://localhost:3000/node_modules/systemjs/dist/system.src.js:4035:18) at linkDynamicModule (http://localhost:3000/node_modules/systemjs/dist/system.src.js:3300:32) at link (http://localhost:3000/node_modules/systemjs/dist/system.src.js:3135:11) at Object.execute (http://localhost:3000/node_modules/systemjs/dist/system.src.js:3510:13) at doDynamicExecute (http://localhost:3000/node_modules/systemjs/dist/system.src.js:766:25) at link (http://localhost:3000/node_modules/systemjs/dist/system.src.js:964:20) at doLink (http://localhost:3000/node_modules/systemjs/dist/system.src.js:623:7) at updateLinkSetOnLoad (http://localhost:3000/node_modules/systemjs/dist/system.src.js:669:18) at http://localhost:3000/node_modules/systemjs/dist/system.src.js:485:11 at ZoneDelegate.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:334:26) at Zone.run (http://localhost:3000/node_modules/zone.js/dist/zone.js:126:43) at http://localhost:3000/node_modules/zone.js/dist/zone.js:713:57 at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:367:31)

这是正在使用(如在教程提供)tsconfig.json文件:

{ 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "lib": [ "es2015", "dom" ], 
    "noImplicitAny": true, 
    "suppressImplicitAnyIndexErrors": true 
    } 
} 

回答

0

尝试添加"alwaysStrict":true到你的tsconfig。正如它错误地说,你需要使用严格模式,这个选项会为你做。

'use strict'; 
+0

'use strict'被添加到已编译的JavaScript文件中,但遗憾的是报告了同样的错误 – jtsnr

相关问题