Chained methods no longer resolving

I don't know exactly what all details are important here, but we've created a class to assist with writing automated tests driven by leadfood. The class has numerous methods that return the class instance so that we can chain methods together. Previously, WebStorm resolved these chained methods no problem. I'm not sure after which specific update, but fairly recently our chained methods have stopped resolving. The first method called directly off of a class instance resolves, and then no methods after that do. JSDocing the methods don't seem to make a difference either. It's difficult to create new tests without code completion. One other coworker doesn't seem to be experiencing the problem, so I'm wondering if it's just a setting somewhere or something else quick I can do before I submit a bug ticket. Here's a small example that recreates our problem:

class Something {
constructor() {

}
doThis() {
return this;
}
doThat() {
return this;
}
doSomething() {
return this;
}
doSomethingElse() {
return this;
}
}

new Something()
.doThis()
.doThat() // Doesn't resolve
.doSomething() // Doesn't resolve
.doSomethingElse(); // Doesn't resolve
0
8 comments

Works fine for me in 2019.1.1 and 2019.1.2 using provided code snippet:

 

Please try invalidating caches (File | Invalidate caches, Invalidate and restart) - does the issue persist?

0
Avatar
Permanently deleted user

Strange, I assume it's something quirky with our installs/settings. Still persists.

0

can you recreate it in a new project?

0
Avatar
Permanently deleted user

Strange, it works fine in new projects, and just to double check, it works for new files I create in my problematic project. But I'm still seeing the problem with the test writing class. 

0

Must be smth specific to your code/dependencies... I can hardly advise unfortunately unless you can share a minimal example that can be used to recreate the issue

0
Avatar
Permanently deleted user

Ah perhaps it's our use of AMD. Our test writing class is declared inside a module to be included in our test files. Wrapping the previously working example immediately recreated the problem for me. Try this:

define([], 
function() {
class Something {
constructor() {

}

doThis() {
return this;
}

doThat() {
return this;
}

doSomething() {
return this;
}

doSomethingElse() {
return this;
}
}

new Something()
.doThis()
.doThat()
.doSomething()
.doSomethingElse();
});

 

0
Avatar
Permanently deleted user

Much appreciated, thanks! 

0

Please sign in to leave a comment.