I\'m looking at moving over to Typescript and currently looking at doing this slowly if possible file by file.
Now the system I currently have is built with Webpack and
Any ideas I have searched quite a lot but I can't really make sense of importing JS files into Typescript.
For webpack all you need is to declare
the require
function and do what you are already used to:
var foo = require('../../../../vendor/src/foo');
The require
function type definition is present here : https://github.com/TypeStrong/ts-loader#loading-other-resources-and-code-splitting
If you want to use foo
in a stronger manner... recommend porting it over to .ts
as well instead of struggling to build and then maintain a .d.ts
file for it.
What about simply rename foo.js
to foo.ts
(it may require some additional steps but often it works fine) and then rewrite your snippet to:
/// <reference path="../../../../vendor/src/foo.d.ts" />
foo('something');