Проблема
Я использую TypeScript v. 1.6.2 для компиляции исходников ts в js с использованием модулей ES5 и system
. Я ожидаю, что JS будет иметь system.register
, заполненный массивом строк, которые представляют импортированные исходные местоположения. Например:
System.register(['angular2/angular2', 'angular2/router', 'angular2/http'],
function(exports_1) { ...
Однако в моем случае system.register
пусто. Я не уверен, почему он пуст, но я явно не могу обойтись без импорта. Ниже приведен набросок моей файловой структуры, пример исходного кода и файл tsconfig.json
.
Структура файла
|index.js
|
|components
|
|--Bike
|
-Bike.ts
Источник
/// <reference path="components/Bike/Bike.ts" />
import { Bike } from 'components/Bike/Bike';
export class TestClass {
public bike: Bike;
constructor(bike: Bike) {
this.bike = bike;
console.log('Bike new TestClass');
}
}
...
export class Bike {
constructor() {
console.log('new bike');
}
}
Вывод
/// <reference path="components/Bike/Bike.ts" />
//NOTICE - no locations in the registry!
System.register([], function(exports_1) {
var TestClass;
return {
setters:[],
execute: function() {
TestClass = (function () {
function TestClass(bike) {
this.bike = bike;
console.log('Bike new TestClass');
}
return TestClass;
})();
exports_1("TestClass", TestClass);
}
}
});
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "system",
"declaration": true,
"removeComments": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"listFiles": true,
"outDir": "target/js"
},
"exclude": [
"node_modules",
"jspm_packages",
"bower_components",
"d3",
"plottable",
"angular2",
"target"
]
}