0

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.

1 Answer 1

3

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.

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

3 Comments

Following the above still leaves me with the same errors :/ I tried referencing the file directly as well as using grunt-ts to create a reference.ts file and referencing that instead. For what it's worth, it does seem that the code is actually building and working now, it just fills my console up with Could not find symbol errors.
+1 nice answer. Could you please elaborate on why you no longer recommend that?
@llya Thanks. From the link github.com/TypeStrong/grunt-ts#reference-file-generation Warning: Using the compiler with --out / reference.ts will slow down a fast compile pipeline. Use external modules with transforms instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.