0

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
1
  • @JonathanLonowski - I updated the question with the locations Commented Jul 15, 2014 at 17:59

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.