Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After adding global typings I can't built project, typings does not seem to register. #323

Open
dewwwald opened this issue Mar 23, 2017 · 1 comment

Comments

@dewwwald
Copy link

dewwwald commented Mar 23, 2017

What I did:

  1. Added mixpanel as an analytics tool.
  2. Add a file app-typings/app.d.ts
declare let API_URL: string;

declare interface People {
  set(personProperties: any): null;
}
declare interface Mixpanel {
  identify(personId: string): null;
  track(eventName: string, eventProperties: any): null;
  people: People;
}

declare let mixpanel: Mixpanel;
  1. install typings ^2.1.0 (the other files are empty
{
  "globalDependencies": {
    "app": "file:./app-typings/app.d.ts",
    "index": "file:./app-typings/index.d.ts",
    "polyfills": "file:./app-typings/polyfills.d.ts",
    "vendor": "file:./app-typings/vendor.d.ts"
  }
}
  1. amend start script in package.json =>
{...
  "start": "typings install --global --save file:./app-typings/app.d.ts && npm run server",
...}
  1. add compiler option in tsconfig.json
    "noImplicitAny": true

  2. Use mixpanel by setting it to a variable. In the constructor of the component.

There is like 3 bug blocks but this is the first after the jargon:
ReferenceError: mixpanel is not defined
at new AnalyticsService (eval at (http://localhost:8080/js/app.js:480:1), :13:46)
at AppModuleInjector.get (/AppModule/module.ngfactory.js:394:77)
at AppModuleInjector.getInternal (/AppModule/module.ngfactory.js:498:56)
at AppModuleInjector.NgModuleInjector.get (eval at (http://localhost:8080/js/vendor.js:1640:1), :155:44)
at CompiledTemplate.proxyViewClass.AppView.injectorGet (eval at (http://localhost:8080/js/vendor.js:2596:1), :165:45)
at CompiledTemplate.proxyViewClass.DebugAppView.injectorGet (eval at (http://localhost:8080/js/vendor.js:2596:1), :584:49)
at CompiledTemplate.proxyViewClass.View_AppComponent0.createInternal (/AppModule/AppComponent/component.ngfactory.js:26:83)
at CompiledTemplate.proxyViewClass.AppView.create (eval at (http://localhost:8080/js/vendor.js:2596:1), :108:21)
at CompiledTemplate.proxyViewClass.DebugAppView.create (eval at (http://localhost:8080/js/vendor.js:2596:1), :551:44)
at CompiledTemplate.proxyViewClass.View_AppComponent_Host0.createInternal (/AppModule/AppComponent/host.ngfactory.js:16:19)
at CompiledTemplate.proxyViewClass.AppView.createHostView (eval at (http://localhost:8080/js/vendor.js:2596:1), :121:21)
at CompiledTemplate.proxyViewClass.DebugAppView.createHostView (eval at (http://localhost:8080/js/vendor.js:2596:1), :568:52)
at ComponentFactory.create (eval at (http://localhost:8080/js/vendor.js:1070:1), :232:25)
at ApplicationRef_.bootstrap (eval at (http://localhost:8080/js/vendor.js:1014:1), :613:57)
at eval (eval at (http://localhost:8080/js/vendor.js:1014:1), :425:89)
at Array.forEach (native)
at PlatformRef_._moduleDoBootstrap (eval at (http://localhost:8080/js/vendor.js:1014:1), :425:42)
at eval (eval at (http://localhost:8080/js/vendor.js:1014:1), :377:27)
at ZoneDelegate.invoke (eval at 938 (http://localhost:8080/js/polyfills.js:795:1), :242:26)
at Object.onInvoke (eval at (http://localhost:8080/js/vendor.js:1119:1), :271:37)
at ZoneDelegate.invoke (eval at 938 (http://localhost:8080/js/polyfills.js:795:1), :241:32)
at Zone.run (eval at 938 (http://localhost:8080/js/polyfills.js:795:1), :113:43)
at eval (eval at 938 (http://localhost:8080/js/polyfills.js:795:1), :520:57)
at ZoneDelegate.invokeTask (eval at 938 (http://localhost:8080/js/polyfills.js:795:1), :275:35)
at Object.onInvokeTask (eval at (http://localhost:8080/js/vendor.js:1119:1), :262:37)
at ZoneDelegate.invokeTask (eval at 938 (http://localhost:8080/js/polyfills.js:795:1), :274:40)
at Zone.runTask (eval at 938 (http://localhost:8080/js/polyfills.js:795:1), :151:47)
at drainMicroTaskQueue (eval at 938 (http://localhost:8080/js/polyfills.js:795:1), :418:35)
at HTMLDocument.ZoneTask.invoke (eval at 938 (http://localhost:8080/js/polyfills.js:795:1), :349:25)

@dewwwald
Copy link
Author

dewwwald commented Mar 23, 2017

Here is an update. Adding var mixpanel = undefined; to the html in head fixes the problem. How can I solve this in a clean way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant