Typescript analysis doesn't understand "exports =" statement?


var m = {

    // functions, etc.


exports = m;

With Resharpe installed, the declaration of m is displayed in grey, as if it is unused.

But the statement "exports = m;" is valid TypeScript meaning that the object m should be the public interface of this module, equivalent to:

module.exports = m;

Comment actions Permalink

Hi, Daniel.

Isn't it "export =" instead of "exports ="?

If not, could you please provide a full example?

Thank you!

Comment actions Permalink

To reproduce it, create a project with VS2013's 'HTML Application with TypeScript' template.

Add this to the bottom of the app.ts file:

var m = {};
export = m;

The m in the first line is grayed. Hover over the m and it says "Local variable 'm' is never used".

My previous description was incorrect as you say - I use CommonJS most of the time, where "exports" is used!

Comment actions Permalink

Thank you very much for making things clear.
I thought that it was about unresolved keyword, but it's about control flow inspection, I see now.

I've created a bug:
Control flow analysis now doesn't take into account several TS-specific constructs, yes. That will be fixed in 9.0.


Please sign in to leave a comment.