我有2个打字稿文件,我想导入它们,但是在Google chorme的控制台中出现错误。
script.ts:
import { Person } from "./modul";
let person = new Person("programmer", "Mitat", 14, "Programmer");
console.log(person.getPersonInfo());
modul.ts:
export class Person {
private name : string;
private surname : string;
private age : number;
private job : string;
constructor (name:string, surname:string, age:number, job:string)
{
this.name = name;
this.surname = surname;
this.age = age;
this.job = job;
}
getPersonInfo()
{
return (
("Name: " + this.name + "\n") +
("Surname: " + this.surname + "\n") +
("Age: " + this.age + "\n") +
("Job: " + this.job)
);
}
}
index.html:
<!DOCTYPE html>
<html>
<head>
<title>TypeScript</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
script.js:2未捕获的ReferenceError:未定义导出 在script.js:2
script.js:
"use strict";
exports.__esModule = true;
var modul_1 = require("./modul");
var person = new modul_1.Person("programmer", "Mitat", 14, "Programmer");
console.log(person.getPersonInfo());