Declaring a larger scope variable type without assigning a value to satisfy JSLint

Can I declare a variable and tell Lint what type it should be, but without giving it a value? I'm having this problem while writing Mocha/Should tests.

If have something like the following:

describe("Test Custom Var", function() {
     var testType = {};

    it("should be successful", function() {
          testType = new TestType(invalid_value);
          result = someFunction(testType);

     it("should be unsuccessful", function() {
         testType = new TestType(valid_value);
          result = someFunction(testType);

I get a warning that someFunction is expecting type TestType, and that argument type {} is not assignable to TestType.

Any ideas on how to fix this?

1 comment
Comment actions Permalink

I found the answer- after I worked out the right Google search...

Turns out I should change
var TestType = {};


/** @type {MyType} */
var TestType;


Please sign in to leave a comment.