4

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?

1 Answer 1

4

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?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.