Reputation: 32758
File: util.ts
class Util {
task1 () {
return 9;
}
}
module.exports = new Util();
File: base.ts
// <reference path="../../Utils/util.ts" />
import util = require('../../Utils/util.js');
class child {
}
I am trying to import the util module but when I do this it gives me an error saying.
Error 1 Unable to resolve external module ''../../Utils/util.js''. C:\Protractor\Latest\Test\Test\Scripts\Admin\Common\base.ts 4 1 Test
Can someone help tell me what I am doing wrong?
Here's the location of my files:
C:\Protractor\Latest\Test\Test\Scripts\Utils\util.js
C:\Protractor\Latest\Test\Test\Scripts\Utils\util.ts
C:\Protractor\Latest\Test\Test\Scripts\Admin\Common\base.ts
Upvotes: 0
Views: 1326
Reputation: 250802
You don't need to use reference comments when using import statements and external modules, so you can remove this line...
// <reference path="../../Utils/util.ts" />
Once your import statement works, it will bring in the type information just like a reference comment. You don't need to include the file extension...
import util = require('../../Utils/util');
Let me know if you are still stuck.
Upvotes: 2