Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constructor support #176

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

BredStik
Copy link

Allows generation of constructors for records and classes when class/record or constructor is marked with [TsConstructorAttribute] AND constructor arguments match both the name and type of generated members of the TS file.

i.e.:

public class MyClass
{
    public string Name {get;set;}
    public int Age {get;set;}
    [TsConstructor]
    public MyClass(string name, int age){}
}

becomes:

export class MyClass {
    constructor(name: string, age: number){
        this.name: name;
        this.age: age;
    }
    name: string;
    age: number;
}

and

[TsConstructor]
public record MyRecord(string name, int age);

becomes

export class MyRecord{
    constructor(name: string, age: number){
        this.name: name;
        this.age: age;
    }
    name: string;
    age: number;
}

Also supports generation of empty constructor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant