1

In my angular app, I'm trying to import an external library Presto.js. I have added the below code

angular.json

"scripts": [
    "./src/assets/presto/Presto.js"
]

example.component.ts

import  * as Presto  from '../../assets/presto/Presto';

ngOnInit() { 
    debugger;
    Presto.layout();
}

When it hits the debugger, I can see the method layout() in it, but when the debug point it released, the below error is thrown

TypeError: _assets_presto_Presto__WEBPACK_IMPORTED_MODULE_6__["layout"] is not a function. 

Does anyone have any idea on this..

Tushar Walzade
  • 3,737
  • 4
  • 33
  • 56
I'm nidhin
  • 2,592
  • 6
  • 36
  • 62
  • 1
    See [this answer](https://stackoverflow.com/a/44817445/3634032) – Sam Herrmann Jan 30 '19 at 13:41
  • You may find it in your `window` object, try with debugger – Tushar Walzade Jan 30 '19 at 14:12
  • @SamHerrmann I already tried this except typings.d.ts, which I can't find in angular 6 app – I'm nidhin Jan 30 '19 at 14:22
  • @TusharWalzade I can find it even with out the window object when I put debug point..but still getting error – I'm nidhin Jan 30 '19 at 14:23
  • You could try [this](https://gist.github.com/jeffwhelpley/2d14a615790af18b3549#gistcomment-2111412) – Tushar Walzade Jan 30 '19 at 14:26
  • Yeah the CLI used to included typings.d.ts by default, but it no longer does. You can add it yourself though and tell the compiler about it. See [here](https://stackoverflow.com/a/48727744/3634032). – Sam Herrmann Jan 30 '19 at 14:30
  • @I'm nidhin did you figure it out? Coincidently I need to add a global library today to a new project and I'm struggling to get the custom typings to work too. This used to be no issue. I'm, using Angular + CLI 7.3.0 and followed the [instructions in the docs](https://angular.io/guide/using-libraries#defining-typings-for-runtime-global-libraries) – Sam Herrmann Feb 01 '19 at 17:51

0 Answers0