TypeScript 的 tsc 编译器在调用 jQuery 和 Flot 代码时发出错误

TypeScript's tsc compiler emits errors when calling jQuery and Flot code

With this code(GitHub 存储库的一个分支)运行 "make" on x86-64 Linux 给我这些错误:

shlomif@telaviv1:~/Download/unpack/to-del/TypeScript-flot$ make tsc --outFile foo.js foo.ts foo.ts(18,12): error TS2345: Argument of type 'string' is not assignable to parameter of type 'JQuery'. foo.ts(47,39): error TS2345: Argument of type '(event: JQueryEventObject, pos: any, item: any) => void' is not assignable to parameter of type 'boolean'. foo.ts(68,39): error TS2345: Argument of type '(event: JQueryEventObject, pos: any, item: any) => void' is not assignable to parameter of type 'boolean'. foo.ts(71,5): error TS2304: Cannot find name 'plot'. foo.ts(74,40): error TS2339: Property 'version' does not exist on type '{ (placeholder: JQuery, data: dataSeries[], options?: plotOptions): plot; (placeholder: JQuery, d...'. Makefile:6: recipe for target 'foo.js' failed make: *** [foo.js] Error 2

有问题的 TypeScript 代码是:

```

$.plot("#placeholder", [ // line 18
        { data: series[0], label: "old-time(iters)", },
        { data: series[1], label: "new-time(iters)", },
    ],
    {
        series: {
            lines: {
                show: true
            },
            points: {
                show: true
            }
        },
        grid: {
            hoverable: true,
            clickable: true
        },
    }
);

```

我正在使用 TypeScript 的 tsc 编译器以及 https://github.com/DefinitelyTyped/DefinitelyTyped and a locally modified version of the jQuery Flot 定义中的 jquery 定义(修复了 tsc 编译器报告的一些其他错误)。

如何修复这些错误?

错误指出它无法在第 18 行将字符串类型分配给 jQuery 类型:

$.plot("#placeholder", [

将第 18 行更改为 jQuery 对象应该可以修复它:

$.plot($("#placeholder"), [