0

I am new to TypeScript and trying to not get off to a bad start. Using TypeScript 2.5.3 within Visual Studio 2017 I am getting intellsense errors saying "Duplicate Identifier 'MyCo'". Am I doing something wrong here and if so how should I be doing this? The code runs as desired but VS intellisense is calling this an error.

MyCo.TestSuite1.ts

namespace MyCo {
  export class TestSuite1 {
    run() {
      alert("MyCo.TestSuite1.run");
    }
  } 
}

MyCo.TestSuite2.ts

namespace MyCo {
  export class TestSuite2 {
    run() {
      alert("MyCo.TestSuite2.run");
    }
  } 
}

App.ts

/// <reference path="MyCo.TestSuite1.ts" />
/// <reference path="MyCo.TestSuite2.ts" />

namespace MyCo {
  export class Main {
    run() {
      var ts1 = new MyCo.TestSuite1();
      ts1.run();
      var ts2 = new MyCo.TestSuite2();
      ts2.run();
    }
  }
}

(function () {
  var main = new MyCo.Main();
  main.run();
})();
MikeO
  • 195
  • 1
  • 10
  • 1
    You should check [this](https://stackoverflow.com/questions/30357634/how-do-i-use-namespaces-with-typescript-external-modules) first and think if you need that namespaces at all. – Aleksey L. Nov 15 '17 at 06:44
  • Unfortunately, I get a runtime error of "exports undefined" when trying the proposed import. I can't seem to find an example that actually works :( – MikeO Nov 15 '17 at 18:39
  • @MikeO,Please try to right click the solution and clean, restart VS , delete .vs folder and bin/obj folders under the solution folder. If you installed the ReSharper, empty the ReSharper cache: ReSharper > Options > Environment > General > Clear Caches and disable and enable ReSharper: Tools > Options > ReSharper > General > Suspend / Restore. – Sara Liu - MSFT Nov 16 '17 at 07:29

1 Answers1

0

You Main class is :

 export class Main {
    run() {
      var ts1 = new MyCo.TestSuite1();
      ts1.run();
      var ts2 = new MyCo.TestSuite2();
      ts2.run();
    }

but your MyCo.TestSuite1.ts has export class TestSuite2 not TestSuite1 Check class names in your .ts file

BRSYNR
  • 41
  • 2
  • Oops copied the wrong code for TestSuite1 example. Fixed now. As I said, the code runs as expected, I just get an intellisense error. – MikeO Nov 15 '17 at 06:34
  • Can you check Typescript version from open Tools > Options > Text Editor > JavaScript/TypeScript > IntelliSense If you need it.Change Use TypeScript version – BRSYNR Nov 15 '17 at 06:39
  • There is no version property in any of those tabs, but under project properties TypeScript Build its set to use 2.5. – MikeO Nov 15 '17 at 06:43