I don't know if theres even a value in this. I'm just curious if it is possible?
if it's possible and what are the syntax for
initializing a const field in constructor in typescript?`
export class Gulpfile {
private dist: string;
private src: string;
constructor(){
const this.dist = './dist/';
this.src = './src'
}
}
You can't have a constant class member.
Mainly because class members are always referenced by reference via the this keyword, and that reference can always be changed.
It's not supported in ES6 either.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With