[K/JS] Generating TypeScript definitions for exceptions and rest of the types ^Fixed KT-53940

This commit is contained in:
Artem Kobzar
2022-12-01 15:01:24 +00:00
committed by Space Team
parent 50ad5027fe
commit 0f0421ea3d
3 changed files with 8 additions and 3 deletions
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.ir.util.isObject
import org.jetbrains.kotlin.ir.util.parentAsClass
import org.jetbrains.kotlin.js.common.isValidES5Identifier
import org.jetbrains.kotlin.serialization.js.ModuleKind
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance
import org.jetbrains.kotlin.utils.addToStdlib.runIf
private const val Nullable = "Nullable"
@@ -318,7 +317,7 @@ class ExportModelToTsDeclarations {
" /* extends $implicitlyExportedClassesString */"
} else {
val originallyDefinedSuperClass = implicitlyExportedClassesString.takeIf { it.isNotEmpty() }?.let { "/* $it */ " }.orEmpty()
val transitivelyDefinedSuperClass = firstIsInstance<ExportedType.ClassType>().toTypeScript(indent, false)
val transitivelyDefinedSuperClass = single { it !is ExportedType.ImplicitlyExportedType }.toTypeScript(indent, false)
" extends $originallyDefinedSuperClass$transitivelyDefinedSuperClass"
}
}
@@ -42,5 +42,8 @@ declare namespace JS_TESTS {
const console: Console;
const error: WebAssembly.CompileError;
function functionWithTypeAliasInside(x: any/* foo.NonExportedGenericInterface<foo.NonExportedType> */): any/* foo.NonExportedGenericInterface<foo.NonExportedType> */;
class TheNewException extends Error {
constructor();
}
}
}
@@ -92,4 +92,7 @@ typealias NotExportedTypeAlias = NonExportedGenericInterface<NonExportedType>
@JsExport
fun functionWithTypeAliasInside(x: NotExportedTypeAlias): NotExportedTypeAlias {
return x
}
}
@JsExport
class TheNewException: Throwable()