To utilize definition files (.d.ts), follow these steps:
Start by verifying if a definition file for foo.js already exists within the community. You can check it out here:
or here https://github.com/DefinitelyTyped/DefinitelyTyped
If the file does exist, you can install it using this command:
npm install --save @types/foo
If not, you have the option to create your own definition file for this javascript file.
Name the file foo.d.ts and include content like this:
declare var data:any;
declare function myFunc(n:string);
Once created, you can treat it like a usual ".ts" file.
import * as foo from "./foo"; //"./foo" indicates the path to your .d.ts file.
foo.myFunc()
For further details, visit: