Skip to content

Commit f36763f

Browse files
committed
fix: class that extends class with FunctionalInterface annotation
1 parent e0574f5 commit f36763f

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
group 'com.github.commandblock2'
18-
version '1.1.0'
18+
version '1.1.1'
1919

2020
buildscript {
2121
ext.kotlin_version = '2.0.0'

src/main/kotlin/me/ntrrgc/tsGenerator/TypeScriptGenerator.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)