0
我想在2015年VS设置的新打字稿 HTML项目,我已经设置了打字稿建立设置CommonJS的,ES5,也有tsconfig.json,这是不能找到导入模块TypeScipt
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true
}
}
这里是我的主要app.ts
import t = require('./test');
class Greeter {
element: HTMLElement;
span: HTMLElement;
timerToken: number;
t: any;
constructor(element: HTMLElement) {
this.element = element;
this.element.innerHTML += "The time is: ";
this.span = document.createElement('span');
this.element.appendChild(this.span);
this.span.innerText = new Date().toUTCString();
this.t = new t.sample.test();
}
start() {
this.timerToken = setInterval(() => this.span.innerHTML = new Date().toUTCString(), 500);
this.t.hello();
}
stop() {
clearTimeout(this.timerToken);
}
}
window.onload =() => {
var el = document.getElementById('content');
var greeter = new Greeter(el);
greeter.start();
};
这里是我的导入模块test.ts
export module sample {
export class test {
constructor() { }
hello =() => {
console.log("Test");
}
}
}
下面是HTML。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>TypeScript HTML App</title>
<link rel="stylesheet" href="app.css" type="text/css" />
<script src="test.js"></script>
<script src="app.js"></script>
</head>
<body>
<h1>TypeScript HTML App</h1>
<div id="content"></div>
</body>
</html>
该项目建立很好,但是当我在浏览器Chrome或IE打开,它会抛出控制台错误,它无法找到测试并且文件从未到浏览器下载。任何一个可以表明什么,我在这里失踪。