Tag Archives: Typescript

Typescript is genius

I’m teaching myself typescript, because why not, and right off the bat I’m blown away by the genius that is using public as a prefix to constructor arguments.
If you haven’t seen it before, it looks like this:

class Human {
    constructor(public name, public age, public job){
        // do more constructor things here
    }
}


And that’s the same as doing this:

class Human {
    constructor(name, age, job){
        this.name = name;
        this.age = age;
        this.job = job;
    }
}


It just takes the argument and sets a field with that same name in the object! It’s not a revolutionary feature, but it saves so much time in the long run. Anyway, back to it. Look forward to reading about my journey through NativeScript soon, possibly, maybe.