Answer the question
In order to leave comments, you need to log in
How to import a js file into a TypeScript project?
Let's say we have a config.js file that defines a constructor function:
function ConfigService () {
this.greeting = function() {console.log('Hello World');}
}
Answer the question
In order to leave comments, you need to log in
Describe the library interface in a .d.ts file. Name this file something like global.d.ts and put it in the root of the project (where all the ts files are, usually the /src folder). You can read more here https://basarat.gitbooks.io/typescript/docs/types/... . Here is the complete documentation https://www.typescriptlang.org/docs/handbook/decla... .
The file itself will look something like this:
// global.d.ts
declare function ConfigService();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question