我使用 JSPM 配置了 systemjs 和 typescript 。如果我不使用插件,它就有效。
tsconfig.json
{
"compilerOptions": {
"module": "system",
"target": "es5",
"sourceMap": true,
},
"exclude": [
"node_modules"
]
}
的package.json
{
"name": "myapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"devDependencies": {
"@types/jquery": "^2.0.40"
},
"keywords": [],
"author": "",
"license": "ISC",
"jspm": {
"dependencies": {
"ts": "github:frankwallis/plugin-typescript@^7.0.5"
},
"devDependencies": {
"typescript": "npm:typescript@^2.0.7"
}
}
}
的src / demo.ts
import $ from "jquery";
export default class Demo{
private v : string;
constructor(v : string){
this.v = v;
}
method(){
console.log(this.v);
$("#list").append("<div>addedd div</div>");
}
}
的src / main.ts
import Demo from "./demo";
new Demo("string").method();
问题是,webstorm识别jquery并显示自动完成功能,但是当我启动应用程序时,浏览器会显示以下错误:
错误:(SystemJS)XHR错误(404 Not Found)loading localhost:3000 / jquery.js 错误:XHR错误(404 Not Found)加载localhost:3000 / jquery.js 将localhost:3000 / jquery.js加载为&#34; jquery&#34;来自localhost:3000 / src / demo.js
我已经使用命令
安装了@ types / jquery npm install --save-dev @types/jquery
修改 config.js 它是由JSPM生成的
System.config({
baseURL: "/",
defaultJSExtensions: true,
transpiler: "typescript",
paths: {
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
map: {
....
}
})