I am struggling to load a .js module which is in the same folder as my .ts file. I have 4 file in the same folder:
index.ts
/// <reference path="./node.d.ts" />
/// <reference path="./foo.d.ts" />
import foo = require('./foo.js');
node.d.ts
Copied from https://github.com/borisyankov/DefinitelyTyped/blob/master/node/node.d.ts
foo.d.ts
declare module "foo" {
export function hello(): void;
}
foo.js
module.exports = {
hello: function() {
console.log('hello');
}
};
When I run tsc index.ts --module commonjs, I get the following error:
index.ts(4,22): error TS2307: Cannot find module './foo.js'.