Gratz44
Gratz44

Reputation: 45

No custom directive completion (PhpStorm 2018.3)

I'm struggling again with my IDE and my projects running under Angular 1.4, ES 5.1. Until now, projects where built with some gulp tasks, and AMD modules + RequireJS + bower for the Angular implementation. Everything was doing the right way (custom directives were auto completed).

I've migrated the whole thing under webpack 4, with everything ruled by some module.exports things and require('lib') (under node 8).

Now my custom directives are no longer auto completed.

I've attached a small example of my implementation, feel free to comment but my only questions are those :

The whole project is working when running a webpack dev server and I've attached a sample

Upvotes: 0

Views: 159

Answers (1)

lena
lena

Reputation: 93748

  • To get your directive recognized, you have to specify restrict value explicitly (WEB-36024):

module.exports = angular .module('app.ziiip', []) .directive('customDirective', function () { return { restrict: 'E', template: require('./partials/custom-directive.html') }; });

  • enabling Node.js coding assistance in Settings | Languages & Frameworks | Node.js and NPM should fix the warning for require; but I'd suggest disabling JavaScript | Node.js | Missing require() statement and JavaScript | General | Missing import statement inspections as well: as you are working in CommonJS context, the IDE expects modules being exported/imported explicitly

  • in node_modules/angular/angular.js, parameter is documented as @param {string|DOMElement} element, and document is resolved to var document: Document in lib.dom.d.ts; PhpStorm can't match types and thus shows the warning. You can suppress it by adding // noinspection JSCheckFunctionSignatures comment

Upvotes: 1

Related Questions