Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does `binary operation argument type newval is not compatible with type string` appear

Tags:

I have the following code and inside of it the WebStorm inspection Binary operation argument type newVal is not compatible with type string appears:

enter image description here

I'm wondering why

Full module code:

define(function (require) {
    "use strict";

    var ng = require('angular');
    require('../ngModule').directive('downloadFile', ['$parse', 'auth.authService', function ($parse, authService) {
        return {
            restrict: 'A',
            link: function (scope, element, attrs) {
                var getter = $parse(attrs.downloadFile);

                scope.$watch(getter, function (path) {
                    if (path !== "") {
                        var form = document.createElement("form");
                        var element1 = document.createElement("input");
                        var element2 = document.createElement("input");

                        form.method = "POST";
                        form.action = path;

                        element1.value = authService.getToken();
                        element1.name = "Authorization";
                        form.appendChild(element1);

                        element.append(form);

                        form.submit();
                        element.empty();
                    }
                });
            }
        };
    }]);
});
like image 619
Max Koretskyi Avatar asked Sep 22 '15 16:09

Max Koretskyi


1 Answers

AngularJS's JSDoc definition makes WebStorm think the path argument is a boolean.

You can make WebStorm stop complaining by adding your own JSDoc:

if (path !== /** @type {boolean} */"") {

like image 115
Dale Smith Avatar answered Sep 20 '22 14:09

Dale Smith