Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 325
Jane Wayne Avatar asked Feb 20 '19 21:02

Jane Wayne


1 Answers

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.

like image 86
Sohail Avatar answered Sep 18 '22 05:09

Sohail