@@ -69,6 +69,32 @@ private static class CCircle2 implements IShape2 {
6969 public double radius ;
7070 }
7171
72+ @ JsonTypeInfo (use = JsonTypeInfo .Id .NAME , property = "kind" )
73+ @ JsonSubTypes ({
74+ @ JsonSubTypes .Type (IRectangle3 .class ),
75+ @ JsonSubTypes .Type (ICircle3 .class ),
76+ })
77+ interface IShape3 {
78+ }
79+
80+ interface IQuadrilateral3 extends IShape3 {
81+ }
82+
83+ interface INamedShape3 extends IShape3 {
84+ String getName ();
85+ }
86+
87+ interface INamedQuadrilateral3 extends INamedShape3 , IQuadrilateral3 {
88+ }
89+
90+ @ JsonTypeName ("rectangle" )
91+ interface IRectangle3 extends INamedQuadrilateral3 {
92+ }
93+
94+ @ JsonTypeName ("circle" )
95+ interface ICircle3 extends INamedShape3 {
96+ }
97+
7298 @ JsonTypeInfo (use = JsonTypeInfo .Id .NAME , property = "kind" )
7399 @ JsonSubTypes ({
74100 @ JsonSubTypes .Type (DiamondB1 .class ),
@@ -166,6 +192,41 @@ public void testTaggedUnionsWithInterfaces() {
166192 Assert .assertEquals (expected , output );
167193 }
168194
195+ @ Test
196+ public void testTaggedUnionsWithOverlappingInterfaces () {
197+ final Settings settings = TestUtils .settings ();
198+ final String output = new TypeScriptGenerator (settings ).generateTypeScript (Input .from (IShape3 .class ));
199+ System .out .println (output );
200+ final String expected = (
201+ "\n " +
202+ "interface IShape3 {\n " +
203+ " kind: 'circle' | 'rectangle';\n " +
204+ "}\n " +
205+ "\n " +
206+ "interface IRectangle3 extends INamedQuadrilateral3 {\n " +
207+ "}\n " +
208+ "\n " +
209+ "interface ICircle3 extends INamedShape3 {\n " +
210+ " kind: 'circle';\n " +
211+ "}\n " +
212+ "\n " +
213+ "interface INamedQuadrilateral3 extends INamedShape3, IQuadrilateral3 {\n " +
214+ " kind: 'rectangle';\n " +
215+ "}\n " +
216+ "\n " +
217+ "interface INamedShape3 extends IShape3 {\n " +
218+ " name: string;\n " +
219+ "}\n " +
220+ "\n " +
221+ "interface IQuadrilateral3 extends IShape3 {\n " +
222+ " kind: 'rectangle';\n " +
223+ "}\n " +
224+ "\n " +
225+ "type IShape3Union = IRectangle3 | ICircle3;\n "
226+ ).replace ('\'' , '"' );
227+ Assert .assertEquals (expected , output );
228+ }
229+
169230 @ Test
170231 public void testTaggedUnionsDisabled () {
171232 final Settings settings = TestUtils .settings ();
0 commit comments