【发布时间】:2017-02-12 11:43:05
【问题描述】:
更新:
我已经修复了在启动时导致应用程序崩溃的模糊错误。这与未编译的 TypeScript 无关。 In the main.ts file in the Git repo我只需要换行:
platformBrowserDynamic().platform.bootstrapModule(AppModule);
收件人:
platformBrowserDynamic().bootstrapModule(AppModule);
现在,当应用启动时,它可以运行而不会出现任何错误。
但是,TypeScript 仍然无法编译 - 我收到以下错误:
node_modules/firebase/firebase.d.ts(391,3): error TS2300: Duplicate identifier 'export='.
typings/globals/firebase/index.d.ts(323,2): error TS2300: Duplicate identifier 'export='.
我的tsconfig.json 文件如下所示:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"typeRoots": [ "../node_modules/@types" ],
"listFiles": true
},
"files": [ "typings/index.d.ts" ],
"include": [ "app/**/*" ]
}
我有一个使用 Firebase (AngularFire2) 作为身份验证和数据库的 Angular 应用。
当我只使用 AngularFire2 库时一切正常,但我需要使用 Firebase 的 ServerValue.TIMESTAMP,从我读到的内容需要导入 Firebase 以及 AngularFire2。
来自网络上的各种来源,包括此处的答案,我相信我现在正在将 Firebase 正确导入我的应用程序。
这需要将"files": [ "typings/index.d.ts" ] 添加到我的tsconfig.json 文件中,例如
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"typeRoots": [ "../node_modules/@types" ],
"listFiles": true
},
"include": [ "../app/**/*.ts" ],
"exclude": [ "../node_modules" ],
"files": [ "typings/index.d.ts" ]
}
还有一个在我的systems.config.js 文件as per this question 中引用的Firebase。
这修复了 TypeScript 编译器抱怨的很多重复错误,但是...
应用程序现在在启动时崩溃,只出现模糊的错误:
[Error] Error:
eval code
eval@[native code]
run@http://localhost:3000/node_modules/zone.js/dist/zone.js:96:49
http://localhost:3000/node_modules/zone.js/dist/zone.js:462:60
invokeTask@http://localhost:3000/node_modules/zone.js/dist/zone.js:236:42
runTask@http://localhost:3000/node_modules/zone.js/dist/zone.js:136:57
drainMicroTaskQueue@http://localhost:3000/node_modules/zone.js/dist/zone.js:368:42
invoke@http://localhost:3000/node_modules/zone.js/dist/zone.js:308:44
Evaluating http://localhost:3000/app/main.js
Error loading http://localhost:3000/app/main.js — system.src.js:123:88
(anonymous function) (localhost:16)
run (zone.js:96)
(anonymous function) (zone.js:462)
invokeTask (zone.js:236)
runTask (zone.js:136)
drainMicroTaskQueue (zone.js:368)
invoke (zone.js:308)
我还认为我在 app 目录中的 TypeScript 文件没有编译。当我记录哪些文件编译时,我在终端中得到以下信息:
[0] /Users/jonathonoates/Sites/my-app/node_modules/typescript/lib/lib.d.ts
[0] /Users/jonathonoates/Sites/my-app/typings/globals/core-js/index.d.ts
[0] /Users/jonathonoates/Sites/my-app/typings/globals/firebase/index.d.ts
[0] /Users/jonathonoates/Sites/my-app/typings/globals/jasmine/index.d.ts
[0] /Users/jonathonoates/Sites/my-app/typings/globals/node/index.d.ts
[0] /Users/jonathonoates/Sites/my-app/typings/index.d.ts
我已经建立了我的Git repo for you to examine here的一个分支。
希望有人熟悉这个问题并可以提供帮助!
【问题讨论】:
标签: angularjs typescript firebase angularfire2