nenoNaninu/Tapper

Primary constructor?

Closed this issue · 2 comments

Hi,

Does primary constructor are supported?

Yes, it is supported. See CustomType3 in README#nesting-types

primary constructors are supported only for records. classes with primary constructor are transpiled into empty types

[TranspilationSource]
public class InfoClass(int id, string nickname)
{
    public int Id { get; } = id;
    public string Nickname { get; } = nickname;
}

[TranspilationSource]
public class InfoClassNonPrimary
{
    public InfoClassNonPrimary(int id, string nickname)
    {
        Id = id;
        Nickname = nickname;
    }

    public int Id { get; }
    public string Nickname { get; }
}

[TranspilationSource]
public record InfoRecord(int id, string nickname)
{
}
/** Transpiled from InfoClass */
export type InfoClass = {
}

/** Transpiled from InfoClassNonPrimary */
export type InfoClassNonPrimary = {
    /** Transpiled from int */
    id: number;
    /** Transpiled from string */
    nickname: string;
}

/** Transpiled from InfoRecord */
export type InfoRecord = {
    /** Transpiled from int */
    id: number;
    /** Transpiled from string */
    nickname: string;
}