Thanks for making Encore.
I've done the following:
In webpack.config.js, PhpStorm is showing the warning "Unresolved method or function setOutputPath()":

I've verified that setOutputPath() exists in node_modules/@symfony/webpack-encore/index.js.
How can I tell PhpStorm where to find the Encore functions?
It looks like it's related to PhpStorm not being able to handle the fact that a Proxy is exported:


I'm not sure how to solve that.
Edit: Note that this is only an IDE issue, Encore should be working as intended
I've also noticed this (I use PhpStorm). Can we add some custom JS doc to the exported Proxy to hint to the IDE about the methods? We could even possibly auto-generate these docs.
Doing something like that seems to actually work:
class Encore {
/**
* @returns {Encore}
*/
method1() {
// (...)
return this;
}
/**
* @param {string} test
* @returns {Encore}
*/
method2(test) {
// (...)
return this;
}
/**
* @param {string} test
* @returns {void}
*/
method3(test) {
// (...)
}
}
/**
* @type {Encore}
*/
module.exports = new Proxy(
new API(),
{ /* ... */ }
);
So we'd need to:
const to a class (I tried to keep the const but for some reason that implied adding a @property tag for each method of the API)@return {exports}/@returns {exports} by @returns {Encore}@type tag to the module.exports and instantiate the classThat sounds great! Nice find!
I had just started to look into https://github.com/DefinitelyTyped/DefinitelyTyped - i.e. you can create a typescript definition (https://www.npmjs.com/package/@types/webpack) and as soon as it's present, your editor uses it for auto-completion. Pretty cool... but it seems that your solution will work perfectly and is quite simple.
Hi, is there any update on this issue? I could try but I'm not node expert, so not sure if it would be of any help at all. @Lyrkan the steps you mentioned, are they still valid ? I could try and do something :slightly_smiling_face:
Do it! I鈥檓 sure those steps are still valid - so this is just a chore we need to get done :)
Fixed by #263 (make sure your PhpStorm is configured to use ES6 and not ES5), thank you @florentdestremau :)
I also get this error, but only on one of my two projects.
In my first project (symfony 3 without flex), setOutputPath is correctly resolved.
In my second project (symfony 4 with flex), setOutputPath is unresolved.
I checked both of my projects and noticed that when I install Encore only with npm (or yarn) i get the 0.19.0 version.
But if I install it with flex, I get the 0.17.0 version, and if I forced it to the 0.1.9.0 in my packages.js, the issue is solved.
Hope it helps others.