初始化器类型 JQuery<TElement> 不可分配给变量类型 JQuery

Initializer type JQuery<TElement> is not assignable to variable type JQuery

这是一个错误,每次我们在 jQuery 循环中初始化 $(this) 时,我们似乎都会在 PhpStorm 中遇到这个错误。经过 hours/days 的研究,我没有找到任何关于 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>

已解决:这一定是PhpStorm的版本问题。从2017.1升级到2017.3后问题消失