Skip to content

Commit

Permalink
[K/JS] Generating TypeScript definitions for exceptions and rest of t…
Browse files Browse the repository at this point in the history
…he types ^Fixed KT-53940
  • Loading branch information
JSMonk authored and Space Team committed Dec 5, 2022
1 parent 1eabf6d commit a7f2dd4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Expand Up @@ -14,9 +14,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.firstIsInstanceOrNull
import javax.lang.model.type.IntersectionType

private const val Nullable = "Nullable"
private const val objects = "_objects_"
Expand Down Expand Up @@ -290,7 +287,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"
}
}
Expand Down
Expand Up @@ -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();
}
}
}
Expand Up @@ -92,4 +92,7 @@ typealias NotExportedTypeAlias = NonExportedGenericInterface<NonExportedType>
@JsExport
fun functionWithTypeAliasInside(x: NotExportedTypeAlias): NotExportedTypeAlias {
return x
}
}

@JsExport
class TheNewException: Throwable()

0 comments on commit a7f2dd4

Please sign in to comment.