初始化器类型JQuery 不能赋予变量类型JQuery

问题描述 投票:2回答:1

每次我们在jQuery的每个循环中初始化$(this)时,这是我们似乎在PhpStorm中得到的错误。经过数小时/天的研究后,我没有找到任何有关为什么PhpStorm将此标记为错误的信息。

我们使用typescript-eslint-parser进行linting,这不会标记任何错误。

这只是PhpStorm的一个问题,还是一个真正的TypeScript错误?

可以解决或忽略吗?

这些是安装的类型:

"@types/axios": "^0.14.0",
"@types/bootstrap": "3.3.36",
"@types/node": "8.5.1",
"@types/jquery": "3.2.7",
"@types/qs": "^6.5.1",

$.fn.extend({
    performanceCharts: function (): JQuery {
        'use strict'
        $(this).each(function (): void {
            let $this: JQuery = $(this)
        });
    }
})

$(document).ready(function () {
    $('.js-performance-charts').performanceCharts()
})
<div class="js-performance-charts"></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
jquery typescript phpstorm webstorm typescript-typings
1个回答
0
投票

解决:这一定是PhpStorm版本的问题。从2017.1升级到2017年3后问题消失了。

© www.soinside.com 2019 - 2024. All rights reserved.