1

I'm using the latest WebStorm EAP 7 130.958.

I have had this buggy behavior since version 6 came out with Typescript support. The problem in the below example code applies "unresolved variable" to BaseClass in the ExtendedClass.ts the moment I add ...

///<reference path="./Interfaces.ts"/>

If I remove reference path the error goes away. This happens any time I extend from a class imported from a node module ONLY when a reference path exists. How did this make it all the way through 6 to 7?

Interfaces.ts

interface IBaseClass {
    str:string;
}

BaseClass.ts

///<reference path="./Interfaces.ts"/>
export class BaseClass implements IBaseClass{
    constructor(public str:string){
        return str+str;
    }
}

ExtendedClass.ts

///<reference path="./Interfaces.ts"/>
import baseClassModule = module("./BaseClass");

class ExtendedClass extends baseClassModule.BaseClass{
    constructor(public str:string){
        super(str);
    }
}

var extendedClass:ExtendedClass = new ExtendedClass("yo");

console.log(extendedClass);

No error present

Error

2 Answers 2

3

This is a bug. You can add ///<reference path="./BaseClass.ts"/> in your ExtendedClass.ts file as a workaround now. Please watch WEB-7645 to get notified when it will be fixed.

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

Comments

0

Modify it to "export interface IBaseClass" and on the other side you need to require it.

At runtime you might get an error loading a js file not there. If so make an empty js file.

My recommendation : do not have a file just with interfaces when using requirejs/commonjs

1 Comment

But I cant reference node.d.ts as the entire web recommends... how can that be right?

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.