[JS/IR] fix: add ability to render type constraints into TypeScript definitions.

This commit is contained in:
Artem Kobzar
2022-07-13 15:20:27 +00:00
committed by Space
parent f1f4ae7359
commit 117df325c9
7 changed files with 18 additions and 3 deletions
@@ -234,6 +234,10 @@ declare namespace JS_TESTS {
function createNested1(): typeof foo.Parent.Nested1;
function createNested2(): foo.Parent.Nested1.Nested2;
function createNested3(): foo.Parent.Nested1.Nested2.Companion.Nested3;
class GenericClassWithConstraint<T extends foo.TestInterface> {
constructor(test: T);
get test(): T;
}
}
namespace _objects_ {
const foo$Parent$Nested1: {
@@ -295,3 +295,6 @@ fun createNested2(): Parent.Nested1.Nested2 {
fun createNested3(): Parent.Nested1.Nested2.Companion.Nested3 {
return Parent.Nested1.Nested2.Companion.Nested3()
}
@JsExport
class GenericClassWithConstraint<T: TestInterface>(val test: T)
@@ -37,6 +37,7 @@ var getParent = JS_TESTS.foo.getParent;
var createNested1 = JS_TESTS.foo.createNested1;
var createNested2 = JS_TESTS.foo.createNested2;
var createNested3 = JS_TESTS.foo.createNested3;
var GenericClassWithConstraint = JS_TESTS.foo.GenericClassWithConstraint;
function assert(condition) {
if (!condition) {
throw "Assertion failed";
@@ -150,5 +151,7 @@ function box() {
assert(createNested1() === nested1);
assert(createNested2() !== nested2);
assert(createNested3() !== nested3);
var genericClassInstance = new GenericClassWithConstraint(new TestInterfaceImpl("test"));
assert(processInterface(genericClassInstance.test) == "Owner TestInterfaceImpl has value 'test'");
return "OK";
}
@@ -37,6 +37,7 @@ import getParent = JS_TESTS.foo.getParent;
import createNested1 = JS_TESTS.foo.createNested1;
import createNested2 = JS_TESTS.foo.createNested2;
import createNested3 = JS_TESTS.foo.createNested3;
import GenericClassWithConstraint = JS_TESTS.foo.GenericClassWithConstraint;
function assert(condition: boolean) {
if (!condition) {
@@ -182,5 +183,9 @@ function box(): string {
assert(createNested1() === nested1)
assert(createNested2() !== nested2)
assert(createNested3() !== nested3)
const genericClassInstance = new GenericClassWithConstraint(new TestInterfaceImpl("test"))
assert(processInterface(genericClassInstance.test) == "Owner TestInterfaceImpl has value 'test'")
return "OK";
}