abstract class Route {
abstract readonly name?: string;
protected abstract pattern: string;
public constructor() {
// Do something with `this.name` and `this.pattern`.
console.log(this.pattern); // Typecheck error
}
abstract handle(): void;
}
Run Code Online (Sandbox Code Playgroud)
这会引发错误,因为this.pattern不会在构造函数中访问。为什么我无法访问它?