I followed this tutorial to create a library for angular https://medium.com/@tomsu/how-to-build-a-library-for-angular-apps-4f9b38b0ed11
Everything is working fine. Now I want to use third party libraries. But I don't know where to tell angular to look for typings.d.ts and declare some types
declare var Foo: any;
Any ideas?
There are 2 ways to do it:
A) simply make a file at the project root named global.d.ts and list your declare module 'x' statements all in that one file.
declare module 'third-party-library-name'
B) 1: Edit your tsconfig file to use the typeRoots property.
2: Add that root folder to the exclude property in the tsconfig file as well.
3: Add a folder for your third-party library in your types directory.
4: Add an index.d.ts file with your typings into that folder.
5: Add your type definition as declare module 'third-party-library-name'
Reference Links: How to add custom "typings" in typescript 2.0 https://www.detroitlabs.com/blog/2018/02/28/adding-custom-type-definitions-to-a-third-party-library/ How to install custom typings?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With