Does typescript have auto-properties yet?

No, TypeScript does not support C#-like auto properties. You have to declare getters and setters with your the usual JS syntax.

While there has been proposals for auto-properties support, none have been accepted. The gist is that this detracts from trying to move TS towards where JS should be, and is unlikely to ever be supported.


Type in VSCode prop and press the "Tab" key.

Property will be generated:

export class Person
{
    private _name: string;
    public get Name(): string
    {
        return this._name;
    }
    public set Name(v: string)
    {
        this._name = v;
    }
}

Tags:

Typescript