/* * TypeScript 可以使用 ES6 的 class 語法 * 但 TypeScript 還可以額外使用靜態型別的那種修飾字: * 如 public, protected, private */ class Employee { // name is public! public name: string; // manager is private, cannot be access from outside private manager: string; public constructor(theName: string, theManager: string) { this.name = theName; this.manager = theManager; } } // get "Win Wu" alert(new Employee("Win Wu", "Max").name); /* get error: * Property 'manager' is * private and only accessible within class 'Employee'. */ // alert(new Employee("Win Wu", "Max").manager);