Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeWriter doesn't find inherited properties

Tags:

typewriter

Typewriter doesn't seem to pull out inherited properties

public class BaseClass
{
    public int Id { get; set; }
}

public class MyClass : BaseClass
{
    public string Name { get; set; }
}

.tst file

namespace ModelNs  {
    $Classes()[
    export class $Name { $Properties()[
        public $name: $Type;]

        public constructor() { }
    }]
}

Output

namespace ModelNs {

    export class MyClass { 
        public method: string;

        public constructor() { }
    }
}

It's missing the Id property.

Yes, I could add the line

public id: number;

to .tst file as a stop gap, but have more properties to add (than this example).

like image 369
wonea Avatar asked Dec 23 '22 23:12

wonea


1 Answers

You can use $BaseClass to access properties from inherited classes e.g.

namespace ModelNs  {
    $Classes()[
    export class $Name { 

        // Inherited properties
        $BaseClass[$Properties[
        public $name: $Type;]]

        $Properties[
        public $name: $Type;]

        public constructor() { }
    }]
}
like image 64
frhagn Avatar answered Mar 15 '23 11:03

frhagn