Skip to content

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.

@BredStik BredStik force-pushed the feature/constructorSupport branch from dc5182a to cc0ac8d Compare October 31, 2023 13:29
@rezaneam
Copy link

rezaneam commented Apr 8, 2025

@jburzynski any plans for this?

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.

2 participants