Skip to content

Commit

Permalink
Fix recursive call to javaToTypeScript.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Schelykalnov committed Sep 3, 2019
1 parent c01a930 commit e55f298
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ private <T> TsBeanModel processBean(SymbolTable symbolTable, Model model, Map<Ty
TsBeanCategory.Data,
isClass,
symbolTable.getSymbol(bean.getOrigin()),
getTypeParameters(bean.getOrigin()),
getTypeParameters(symbolTable, bean.getOrigin()),
parentType,
extendsList,
implementsList,
Expand All @@ -318,13 +318,13 @@ private boolean mappedToClass(Class<?> cls) {
return cls != null && !cls.isInterface() && settings.getMapClassesAsClassesFilter().test(cls.getName());
}

private List<TsType.BoundedGenericVariableType> getTypeParameters(Class<?> cls) {
private List<TsType.BoundedGenericVariableType> getTypeParameters(SymbolTable symbolTable, Class<?> cls) {
final List<TsType.BoundedGenericVariableType> typeParameters = new ArrayList<>();
for (TypeVariable<?> typeParameter : cls.getTypeParameters()) {
final List<TsType> bounds = new ArrayList<>();
for (Type bound : typeParameter.getBounds()) {
if (!Object.class.equals(bound)) {
bounds.add(javaToTypeScript(bound));
bounds.add(typeFromJava(symbolTable, bound));
}
}
switch (bounds.size()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,19 @@ public void testGenericBoundsParameter() {
assertEquals(expected, output.trim());
}

@Test
public void testGenericRecirsiveBoundsParameter() {
final Settings settings = TestUtils.settings();
final String output = new TypeScriptGenerator(settings).generateTypeScript(Input.from(H.class));
final String nl = settings.newline;
final String expected =
"interface H<T, S extends H<T, S>> {" + nl +
" x: T;" + nl +
" y: S;" + nl +
"}";
assertEquals(expected, output.trim());
}

class A<U,V> {
public A<String, String> x;
public A<A<String, B>, List<String>> y;
Expand Down Expand Up @@ -181,6 +194,11 @@ class G<T extends F> {
public T x;
}

class H<T, S extends H<T, S>> {
public T x;
public S y;
}

abstract class IA implements IB<String>, Comparable<IA> {
}

Expand Down

0 comments on commit e55f298

Please sign in to comment.