|
@@ -1,25 +0,0 @@
|
|
|
-interface Employee {
|
|
|
- name: string;
|
|
|
- title: string;
|
|
|
- logID: () => string;
|
|
|
-}
|
|
|
-
|
|
|
-// Implements Employee and more, so:
|
|
|
-// - can be used as an Employee parameter
|
|
|
-// - is not of type Employee
|
|
|
-// TS calls this a "structural type system" aka "duck typing": interfaces as
|
|
|
-// matches as implemented even when not declared, like in Go.
|
|
|
-let dev = {
|
|
|
- name: 'hr',
|
|
|
- title: 'senior TS dev',
|
|
|
- editor: 'VSCode',
|
|
|
-};
|
|
|
-
|
|
|
-let newEmployee : Employee = { ...dev, logID: () => this.name };
|
|
|
-
|
|
|
-function foo(e: Employee) {
|
|
|
- console.log(e.name + ": " + e.title);
|
|
|
-}
|
|
|
-
|
|
|
-// foo(dev);
|
|
|
-foo(newEmployee);
|