Skip to content

Commit e660771

Browse files
committed
Emit interface with inheritance.
1 parent cbcd448 commit e660771

File tree

4 files changed

+59
-2
lines changed

4 files changed

+59
-2
lines changed

spec/FileEmitterSpec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ describe("UseCases", function () {
6363
runCase("Enum");
6464
runCase("Property");
6565
runCase("Class");
66-
66+
runCase("Interface");
67+
6768
runCase("AspNetCoreControllerToAngularClient", () => {
6869
var controllerClassFilter = (classObject: CSharpClass) => {
6970
var isTypeController = (type: {name: string}) => type.name.endsWith("Controller");

spec/cases/Interface.case.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
interface IBefore
2+
{
3+
string MyProperty { get; set; }
4+
5+
void MyMethod(string foo, params string[] bar);
6+
7+
void MyNullParameterMethod(string foo = null);
8+
9+
Task<IEnumerable<string>> TaskArrayMethod();
10+
}
11+
12+
interface IMain<Foo> where Foo : new()
13+
{
14+
string MyProperty { get; set; }
15+
16+
SomeStuff<OtherStuff, RegularStuff> BlahProperty { get; set; }
17+
18+
List<OtherStuff> OtherBlahProperty { get; set; }
19+
}
20+
21+
interface IOther
22+
{
23+
string MyProperty { get; set; }
24+
}
25+
26+
interface IGeneric<T>
27+
{
28+
T MyProperty { get; set; }
29+
}
30+
31+
interface IConcreteType : IGeneric<long>
32+
{
33+
}

spec/cases/Interface.expected.d.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
declare interface IBefore {
2+
myProperty: string;
3+
myMethod(foo: string, ...bar: Array<string>): void;
4+
myNullParameterMethod(foo?: string): void;
5+
taskArrayMethod(): Promise<Array<string>>;
6+
}
7+
8+
declare interface IMain<Foo> {
9+
myProperty: string;
10+
blahProperty: SomeStuff<OtherStuff, RegularStuff>;
11+
otherBlahProperty: Array<OtherStuff>;
12+
}
13+
14+
declare interface IOther {
15+
myProperty: string;
16+
}
17+
18+
declare interface IGeneric<T> {
19+
myProperty: T;
20+
}
21+
22+
declare interface IConcreteType extends IGeneric<number> {
23+
}

src/InterfaceEmitter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export class InterfaceEmitter {
7777
if (!options.filter(interfaceObject))
7878
return [];
7979

80-
if (interfaceObject.properties.length === 0 && interfaceObject.methods.length === 0) {
80+
if (interfaceObject.properties.length === 0 && interfaceObject.methods.length === 0 && interfaceObject.implements.length === 0) {
8181
this.logger.log("Skipping emitting body of interface " + interfaceObject.name + " because it contains no properties or methods");
8282
return [];
8383
}

0 commit comments

Comments
 (0)