Skip to content

Commit e9b4b6e

Browse files
committed
feat(api): added support for inheritance thanks to @lavinski
feat(docs): updated docs to replace limitations with examples of new generic and inheritance features.
1 parent a3f96e3 commit e9b4b6e

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

README.md

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,41 @@ declare namespace Api {
179179
}
180180
```
181181

182-
## Limitations
182+
## Inheritance
183183

184-
### Inheritance
184+
Types that inherit from other types will be rendered with TypeScript `extends`:
185185

186-
Inheritance isn't directly supported by Typescriptr, in that types passed into the generator that have base clases will not, in the output, also derive from that base class. Instead, base types that aren't `object` or `ValueType` will be rendered with all of their respective publicly available properties. The resulting effect is the same as with inheritance, but with slightly larger code output, and simpler generator code.
186+
```csharp
187+
class BaseClass
188+
{
189+
public string Property { get; set; }
190+
}
191+
192+
class TypeWithBaseClass : BaseClass
193+
{
194+
}
195+
```
196+
197+
```TypeScript
198+
interface TypeWithBaseClass extends BaseClass {
199+
}
200+
interface BaseClass {
201+
property: string;
202+
}
203+
```
204+
205+
## Generics
187206

188-
### Generics
207+
Types with both open and closed generic types will be rendered to TypeScript generics:
189208

190-
Top level types with type parameters are not supported at all. Properties with generic type parameters may be mapped with custom property type formatters, but a non-generic base type is required to match the type on. This scenario is fairly obscure and untested, as generics are unusual for DTO's.
209+
```csharp
210+
class Pie<Apple> { }
211+
class Apple { }
212+
```
213+
214+
```TypeScript
215+
interface Pie<Apple> {
216+
}
217+
interface Apple {
218+
}
219+
```

0 commit comments

Comments
 (0)