Luigi
Luigi

Reputation: 5603

Webstorm Typescript support - Could not find symbol?

I have code like this in my .ts file

test.control('test-change', TestChange);

My test module is initialized in lib/test.ts, and it is properly transpiling to test.js.

However, when I write the above code, webstorm throws this error on that line of code:

error TS2095: Could not find symbol 'test'.

Is there any solution within Webstorm to avoid this error? The code seems perfectly fine, and it even worked previously. I am also using code that has worked within Visual Studio, so it seems like the code is not the issue here.

Upvotes: 0

Views: 1318

Answers (1)

basarat
basarat

Reputation: 276393

Visual studio implicitly includes all TypeScript files in your project into the global namespace. For compiling with tsc manually or using Webstorm / whatever else you need to have explicit references.

/// <reference path="../path/to/lib/test.ts"/>

You can potentially just use a reference.ts https://github.com/grunt-ts/grunt-ts#reference-file-generation although I no longer recommend that

Grunt-ts can take ///ts:ref=test and generate a reference tag for you.

Upvotes: 3

Related Questions