mirror of
https://github.com/alrayyes/wiki.git
synced 2024-11-22 19:46:23 +00:00
569 B
569 B
date | id | title |
---|---|---|
2020-10-09 | b6fa7fa7-644f-42ab-bee6-71f4f58a60f2 | TypeScript Classes |
TypeScript 4.0
Class Property Inference from Constructors
TypeScript 4.0 can now use control flow analysis to determine the types of properties in classes when noImplicitAny is enabled.
class Square {
// Previously: implicit any!
// Now: inferred to `number`!
area;
sideLength;
constructor(sideLength: number) {
this.sideLength = sideLength;
this.area = sideLength ** 2;
}
}