0.8.0.0 to 0.8.1.1 my imported modules are private??

Topics: General
Dec 6, 2012 at 10:56 AM
Edited Dec 6, 2012 at 4:20 PM

I just upgraded from TypeScript 0.8.0.0 to 0.8.1.1 and all of a sudden all my ts files have errors like

 

property 'MyProperty' of exported interface has or is using private type 'MyModule'

exported interface 'MyInterface; extends interface from private module 'MyModule'

exported class's constructor parameter 'myParameter' has or is using private type 'MyModule'

public function parameter 'myParameter' has or is using private type 'MyModule'

public member 'myMember' of exported class has or is using private type 'MyModule'

 

where MyModule refers to the identifier of an imported module like so:

import MyModule = module("MyModule");

this was not a problem with TypeScript 0.8.0.0. I have no idea how to fix it. Can anybody help please?

 

Dec 6, 2012 at 12:53 PM

Had this problem as well, ended up downgrading until someone posts an answer

Dec 6, 2012 at 2:09 PM

In the instances I've seen of this, it means what it says;-) Your exporting module exports an item, but not its type/interface, so the importing module can refer to the item, but not to its type/interface. Usually, you'll want to export the type/interface as well.

Dec 6, 2012 at 4:10 PM

The issue is as follows:

file ModuleA.ts:

export interface InterfaceA{
}

file ModuleB.ts:

import ModuleA = module("ModuleA");

export interface InterfaceB extends ModuleA.InterfaceA{
}

With TypeScript 0.8.1.1 this generates an error in file ModuleB.ts saying exported interface InterfaceB extends interface from private module ModuleA. With TypeScript 0.8.0.0 this does not generate an error.

Dec 6, 2012 at 7:07 PM

I would also add that this worked in 0.8.1.0. It's 0.8.1.1 that adds the additional check. I haven't come up with a solution yet so I'll probably have to downgrade for now if no solution is found.

Dec 6, 2012 at 7:12 PM

I figured it out. You can actually export your imports:

export import MyModule = module('MyModule');

export class MyClass extends MyModule.MyBaseClass {
}

Dec 6, 2012 at 7:13 PM

wow

Dec 6, 2012 at 7:34 PM

well done! That does the trick. I never would have guessed that.

Coordinator
Dec 11, 2012 at 5:19 PM

This is popping up on a few threads.  It looks like this was a bug introduced in 0.8.1.1.  

Imports should "just work" without having to do anything extra to be able to use and extend them.  You shouldn't have to re-export your imports just to use them.

Additionally, being able to re-export imports sounds like something that probably shouldn't be allowed.

Dec 11, 2012 at 6:16 PM

Glad to hear that. I've been avoiding 0.8.1.1 because of this and am glad I didn't go and export all of my imports. 0.8.1.2 please ;-)