Jak mogę debugować modułowy TypeScript z mapami źródłowymi?
Nie mogę znaleźć czasu na debugowanie TypeScript w narzędziach Dev Dev. Wygenerowałem mapy źródłowe dla wszystkich moich plików .ts, a javascript wygląda poprawnie, ale Chrome ładuje tylko plik js, do którego odwołuje się index.html i ignoruje wszystkie moduły. Ma to sens, ponieważ kompilator Typescript nie robi nic z moimi modułami. Gdyby ktoś mógł wyjaśnić, co robię źle w poniższym przykładzie, byłoby świetnie.
Moje ustawienia projektu są następujące:
root/
src/
Company.ts
User.ts
app.ts
index.html
Company.ts
module Company {
export class Job {
public title:string;
public description:string;
constructor(title:string, desc:string){
this.title = title;
this.description = desc;
};
}
}
User.ts
///<reference path="Company.ts"/>
module User {
export class Person {
public first:string;
public last:string;
private myJob:Company.Job;
private myAccount:User.Account;
constructor(firstName:string, lastName:string){
this.first = firstName;
this.last = lastName;
}
public getName():string{
return this.first + ' ' + this.last;
}
public setJob(job:Company.Job){
this.myJob = job;
}
public setAccount(acct:User.Account){
this.myAccount = acct;
}
public toString():string{
return "User: " + this.getName()
+ "\nUsername: " + this.myAccount.userName
+ "\nJob: " + this.myJob.title;
}
}
export class Account {
public userName:string;
private _password:string;
constructor(user:Person){
this.userName = user.first[0] + user.last;
this._password = '12345';
}
}
}
app.ts
///<reference path="src/User.ts"/>
///<reference path="src/Company.ts"/>
(function go(){
var user1:User.Person = new User.Person('Bill','Braxton');
var acct1:User.Account = new User.Account(user1);
var job1:Company.Job = new Company.Job('Greeter','Greet');
user1.setAccount(acct1);
user1.setJob(job1);
console.log(user1.toString());
}());
index.html
<!DOCTYPE html>
<html>
<head>
<title>TypeScript Test</title>
<script src="app.js"/>
<script>
go();
</script>
</head>
<body>
</body>
</html>
Polecenie kompilatora
tsc --sourcemap --target ES5 --module commonjs file.ts
Kiedy otworzę index.html w Chrome i otworzę panel Źródła Narzędzia Dev Dev, pokaże mi app.js i app.ts, ale nie inne moduły .ts. Więc mapa źródłowa dla app.ts działa, ale jak załadować inne moduły, aby można je było debugować w Chrome?