I have 2 typescript files, first app.ts file input point and the second mobiles.ts file the module contains interfaces and classes System of modules CommonJS, an ECMAScript version ES5 is set.
Contents of the file mobiles.ts
export interface Device {
model: string;
company: string;
displayInfo(): void;
}
export class Smartphone implements Device {
model: string;
company: string;
displayInfo(): void {
console.log(`Smartphone. Model: ${this.model} - Company: ${this.company}`);
}
}
export class Tablet implements Device {
model: string;
company: string;
displayInfo(): void {
console.log(`Tablet. Model: ${this.model} - Company: ${this.company}`);
}
}
Contents of the file app.ts
import {Smartphone} from "./mobiles";
window.onload = () => {
let mi: Smartphone = new Smartphone();
mi.company = "Xiaomi";
mi.model = "RedMi 4 Pro";
mi.displayInfo();
};
after a compilation contents of the file mobiles.js
"use strict";
var Smartphone = (function () {
function Smartphone() {
}
Smartphone.prototype.displayInfo = function () {
console.log("Smartphone. Model: " + this.model + " - Company: " + this.company);
};
return Smartphone;
}());
exports.Smartphone = Smartphone;
var Tablet = (function () {
function Tablet() {
}
Tablet.prototype.displayInfo = function () {
console.log("Tablet. Model: " + this.model + " - Company: " + this.company);
};
return Tablet;
}());
exports.Tablet = Tablet;
after a compilation contents of the file app.js
"use strict";
var mobiles_1 = require("./mobiles");//Get Error here
window.onload = function () {
var mi = new mobiles_1.Smartphone();
mi.company = "Xiaomi";
mi.model = "RedMi 4 Pro";
mi.displayInfo();
};
//# sourceMappingURL=app.js.map
Сборка персонального компьютера от Artline: умный выбор для современных пользователей