Reputation: 32758
I recently asked a question but couldn't really understand the answer. Here's what I have been able to understand. Can someone please verify if this is the correct way to go about doing something similar to C# where I have namespaces? Note that below are three files and they all have references to each other but these are not show here:
/Admin/dialog/start.ts
module Admin.dialog {
export function x() { };
Admin.grid.y(); // executes the function inside of file2.ts
}
/Admin/dialog/file1.ts
module Admin.dialog {
export function y() { };
}
/Admin/grid/file2.ts
module Admin.grid {
export function y() { };
}
Upvotes: 0
Views: 82
Reputation: 250842
Here is my suggested structure:
./Admin/Dialog.ts
module Admin {
export class Dialog {
x() {
this.y();
}
y() {
}
}
}
./Admin/Grid.ts
module Admin {
export class Grid {
y() {
}
}
}
You can then use these modules like this:
///<reference path="./Admin/Dialog.ts" />
///<reference path="./Admin/Grid.ts" />
var dialog = new Admin.Dialog();
dialog.x();
var grid = new Admin.Grid();
grid.y();
Upvotes: 2