mirror of
https://github.com/swc-project/swc.git
synced 2024-12-01 01:13:56 +03:00
25 lines
554 B
TypeScript
25 lines
554 B
TypeScript
// Initializer expressions for instance member variables are evaluated in the scope of the class constructor body but are not permitted to reference parameters or local variables of the constructor.
|
|
|
|
class C {
|
|
a = x; // error
|
|
b: typeof x; // error
|
|
constructor(x) { }
|
|
}
|
|
|
|
class D {
|
|
a = x; // error
|
|
b: typeof x; // error
|
|
constructor(public x) { }
|
|
}
|
|
|
|
class E {
|
|
a = this.x; // ok
|
|
b: typeof this.x; // ok
|
|
constructor(public x) { }
|
|
}
|
|
|
|
class F<T> {
|
|
a = this.x; // ok
|
|
b = x; // error
|
|
constructor(public x: T) { }
|
|
} |