jspm / jQuery / TypeScript - 模块“jquery”没有默认导出

jspm / jQuery / TypeScript - module "jquery" has no default export

本文关键字:默认 TypeScript jQuery 模块 jspm jquery      更新时间:2023-09-26

我正在尝试使用TypeScript和jspm&system.js引导Web应用程序进行模块加载。我走得不远。安装 jspm 后,并使用它来安装 jQuery:

jspm install jquery

和基础知识:

<script src="jspm_packages/system.js"></script>
<script src="config.js"></script>
<script>
        System.import('main');
</script>

主要.ts:

import $ from "jquery";
export class Application  {
    constructor() {
        console.log($);
    }
}

TypeScript 不会编译,因为"模块'jquery'没有默认导出。

生成的配置.js具有正确的映射:"jquery": "npm:jquery@2.2.0"

当模块没有默认导出时,您可以将整个模块作为对象导入: import * as $ from "jquery";

或导入指定导出: import { ajax, css } from "jquery";

如果您使用的是visual studio,请更新打字稿插件。

要获取Visual Studio 2017的最新版本,请转到此处