How do I add a typings.d.ts file to an Angular 7 project?

14,279

Just as you yourself said, create the typings.d.ts file in src folder and put your declarations there. That is what I do for stripe and also jquery and works fine.

declare var $: any;
declare var stripe: any;
declare var elements: any;

My latest project is on Angular 8 and worked with the same method.

Share:
14,279

Related videos on Youtube

Jane Wayne
Author by

Jane Wayne

Updated on September 15, 2022

Comments

  • Jane Wayne
    Jane Wayne over 1 year

    I am following this tutorial here, and the author says to add two declarations to the project's typings.d.ts file. However, when using the ng-cli to create the Angular 7 project, there is no such file generated.

    In this other article (for Angular 2), the author suggests to create a typings folder and place the typings.d.ts there and to modify the tsconfig.json file with a files key; doing this gives me a TS5023: Uknown compiler option 'files'. message.

    Yet, in this post, the top answer suggest that typings.d.ts should have been created with ng-cli under the src folder, but I don't see it (I am using Angular CLI v7.3.1).

    My question is, for Angular 7, how and where do I add typings.d.ts? What other files do I need to modify when adding such file?

    • Jane Wayne
      Jane Wayne about 5 years
      @Pytth I did not try that but I just went ahead and created a typings.d.ts under the src and everything works (so far). Still, though, would be nice for some official point of view and/or documentation around these types of integration problems/patterns.
  • NobodySomewhere
    NobodySomewhere over 3 years
    So basically you are just suggesting to use the NPM to download the library instead of doing it manually? How exactly does that fix the problem of using pure JS libraries within angular?
  • Ilia
    Ilia over 3 years
    Do or do not, at the time of the comment, I had minimal experience.. But, I had managed to get what I wanted from that library. The author never requested a pure JS lib solution, but please, feel free to downvote.