How to add TypeScript user-defined global interfaces

I have several interfaces that I use throughout the CommonJS typescript project. I would like to create a global file called "interfaces.ts" ... Instead of importing an interface or adding a link to each .ts (template) file, is there a way to declare it globally, possibly in a tsconfig.json file?

I know that there is a global lib.d.ts definition file, which is basically globally declared interfaces. I understand that I can possibly change this file, but I was looking for a better way (abstraction).

Edit: I should notice that I'm currently using Visual Studio code.

+6
source share
2 answers

That the tsconfig.json path works by default. Create tsconfig.json in the root of your project without the "files" property. You may need to restart the VS code so that it recognizes tsconfig.json .

If tsconfig.json does not have the "files" property, then by default the compiler includes all files containing a directory and subdirectories. When the "files" property is specified, only those files are included.

https://github.com/Microsoft/TypeScript/pull/1692

+3
source

. I understand that I can possibly change this file, but was looking for a better way (abstraction)

You have a file called globals.d.ts . This template is described here: http://basarat.gitbooks.io/typescript/content/docs/project/globals.html

0
source

All Articles