How do I add a typings.d.ts file to an Angular 7 project?
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.
Related videos on Youtube
Jane Wayne
Updated on September 15, 2022Comments
-
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 theng-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 thetypings.d.ts
there and to modify thetsconfig.json
file with afiles
key; doing this gives me aTS5023: Uknown compiler option 'files'.
message.Yet, in this post, the top answer suggest that
typings.d.ts
should have been created withng-cli
under thesrc
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 about 5 years@Pytth I did not try that but I just went ahead and created a
typings.d.ts
under thesrc
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 over 3 yearsSo 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 over 3 yearsDo 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.