【发布时间】:2016-07-10 20:59:47
【问题描述】:
使用 tsc 1.8.9...为什么这些导入不起作用?我以为 TypeScript 实现了 ES6 模块语法?
“类/person.ts”
export default class Person {
protected _name: string;
protected _language: string;
constructor(name: string) {
this._name = name;
this.hello();
}
public hello() {
console.log("Hello, " + this._name);
console.log("Lang: " + this._language);
}
}
“类/englishman.ts”
import Person from "person"
export default class Englishman extends Person {
constructor(name: string){
this._language = "en_GB";
super(name);
}
}
“main.ts”
import * as $ from "jquery";
import Englishman from "classes/englishman";
let tom: Person = new Englishman("Tom");
console.log(tom);
$("body").html(`<h1>TEST</h1>`);
错误:
source/main.ts(2,24): 错误 TS2307: 找不到模块 '课程/英语'。源/main.ts(4,10):错误 TS2304:找不到 名称“人”。 [13:53:43] TypeScript:2 个语义错误
【问题讨论】:
标签: module typescript ecmascript-6