@@ -152,7 +152,11 @@ class TypeScriptGenerator(
152152 }
153153
154154
155- private fun formatKType (kType : KType , isInTypeConstraint : Boolean = false): TypeScriptType {
155+ private fun formatKType (
156+ kType : KType ,
157+ isInTypeConstraint : Boolean = false,
158+ transformFunctionalInterface : Boolean = true
159+ ): TypeScriptType {
156160 val classifier = kType.classifier
157161 if (classifier is KClass <* >) {
158162 val existingMapping = predefinedMappings[classifier]
@@ -173,7 +177,7 @@ class TypeScriptGenerator(
173177
174178 val javaClass = classifier.java
175179
176- if (isFunctionalInterface(javaClass)) {
180+ if (isFunctionalInterface(javaClass) && transformFunctionalInterface ) {
177181 formatFunctionalInterfaceType(javaClass, kType)
178182 } else {
179183 predefinedMappings.getOrDefault(
@@ -315,16 +319,16 @@ class TypeScriptGenerator(
315319 val extendsString = if (supertypes.isNotEmpty()) {
316320 if (klass.java.isInterface) {
317321 " extends " + supertypes.joinToString(" , " ) {
318- formatKType(it).formatWithoutParenthesis()
322+ formatKType(it, false , false ).formatWithoutParenthesis()
319323 }
320324 } else {
321325 val extendsClause = classSupertypes.take(1 ).map {
322- " extends ${formatKType(it).formatWithoutParenthesis()} "
326+ " extends ${formatKType(it, false , false ).formatWithoutParenthesis()} "
323327 }.firstOrNull() ? : " "
324328
325329 val implementsClause = if (interfaceSupertypes.isNotEmpty()) {
326330 " implements " + interfaceSupertypes.joinToString(" , " ) {
327- formatKType(it).formatWithoutParenthesis()
331+ formatKType(it, false , false ).formatWithoutParenthesis()
328332 } + " "
329333 } else " "
330334
@@ -368,7 +372,7 @@ class TypeScriptGenerator(
368372 formatKType(bound) // unused result but needs to record dependencies
369373 " Object | number | string | boolean"
370374 } else
371- formatKType(bound, true ).formatWithoutParenthesis()
375+ formatKType(bound, true , false ).formatWithoutParenthesis()
372376 }
373377 } else {
374378 " "
0 commit comments