📜 未完成 | Reflect

Reflect 是 ES6 的一个 api。和 proxy 相关。

let user = {};

Reflect.set(user, "name", "John");

alert(user.name); // John
1
2
3
4
5

ts-node

Ts-node 可以直接运行 ts

yarn global add ts-node
1

Metadata

元数据就是一个 map ,把关键信息存下来,要用的时候,取出来。

Decorators

Class Decorators

If the class decorator returns a value, it will replace the class declaration with the provided constructor function.

如果类装饰器返回一个值,它将用提供的构造函数替换类声明。

function reportableClassDecorator(constructor): any {
  return class extends constructor {
    reportingURL = "http://www...";
  };
}

@reportableClassDecorator
class BugReport {
  type = "report";
  title: string;

  constructor(t: string) {
    this.title = t;
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15