[K/JS] fix(Interface Export): prevent structural identity between two interfaces.

This commit is contained in:
Artem Kobzar
2022-06-28 15:44:38 +00:00
committed by Space
parent c3c09aa95a
commit 133c6713ca
17 changed files with 133 additions and 122 deletions
@@ -1,7 +1,5 @@
declare namespace JS_TESTS {
type Nullable<T> = T | null | undefined
const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
namespace foo {
class TestInner {
constructor(a: string);
@@ -1,7 +1,5 @@
declare namespace JS_TESTS {
type Nullable<T> = T | null | undefined
const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
class ClassWithDefaultCtor {
constructor();
get x(): string;
@@ -1,7 +1,5 @@
declare namespace JS_TESTS {
type Nullable<T> = T | null | undefined
const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
namespace foo {
const _val: number;
let _var: number;
@@ -138,13 +136,24 @@ declare namespace JS_TESTS {
interface TestInterface {
readonly value: string;
getOwnerName(): string;
readonly __doNotUseIt: __doNotImplementIt;
readonly __doNotUseOrImplementIt: {
readonly "foo.TestInterface": unique symbol;
};
}
interface AnotherExportedInterface {
readonly __doNotUseOrImplementIt: {
readonly "foo.AnotherExportedInterface": unique symbol;
};
}
class TestInterfaceImpl implements foo.TestInterface {
constructor(value: string);
get value(): string;
getOwnerName(): string;
readonly __doNotUseIt: __doNotImplementIt;
readonly __doNotUseOrImplementIt: foo.TestInterface["__doNotUseOrImplementIt"];
}
class ChildTestInterfaceImpl extends foo.TestInterfaceImpl implements foo.AnotherExportedInterface {
constructor();
readonly __doNotUseOrImplementIt: foo.TestInterfaceImpl["__doNotUseOrImplementIt"] & foo.AnotherExportedInterface["__doNotUseOrImplementIt"];
}
function processInterface(test: foo.TestInterface): string;
class OuterClass {
@@ -202,10 +202,16 @@ interface TestInterface {
}
@JsExport
class TestInterfaceImpl(override val value: String) : TestInterface {
interface AnotherExportedInterface
@JsExport
open class TestInterfaceImpl(override val value: String) : TestInterface {
override fun getOwnerName() = "TestInterfaceImpl"
}
@JsExport
class ChildTestInterfaceImpl(): TestInterfaceImpl("Test"), AnotherExportedInterface
@JsExport
fun processInterface(test: TestInterface): String {
return "Owner ${test.getOwnerName()} has value '${test.value}'"
@@ -1,7 +1,5 @@
declare namespace JS_TESTS {
type Nullable<T> = T | null | undefined
const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
namespace foo {
@@ -1,10 +1,10 @@
declare namespace JS_TESTS {
type Nullable<T> = T | null | undefined
const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
namespace foo {
interface ExportedInterface {
readonly __doNotUseIt: __doNotImplementIt;
readonly __doNotUseOrImplementIt: {
readonly "foo.ExportedInterface": unique symbol;
};
}
function producer(value: number): any/* foo.NonExportedType */;
function consumer(value: any/* foo.NonExportedType */): number;
@@ -22,11 +22,11 @@ declare namespace JS_TESTS {
}
class D implements foo.ExportedInterface/*, foo.NonExportedInterface */ {
constructor();
readonly __doNotUseIt: __doNotImplementIt;
readonly __doNotUseOrImplementIt: foo.ExportedInterface["__doNotUseOrImplementIt"];
}
class E /* extends foo.NonExportedType */ implements foo.ExportedInterface {
constructor();
readonly __doNotUseIt: __doNotImplementIt;
readonly __doNotUseOrImplementIt: foo.ExportedInterface["__doNotUseOrImplementIt"];
}
class F extends foo.A /* implements foo.NonExportedInterface */ {
constructor();
@@ -1,7 +1,5 @@
declare namespace JS_TESTS {
type Nullable<T> = T | null | undefined
const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
namespace foo {
interface I<T, S, U> {
x: T;
@@ -43,7 +41,9 @@ declare namespace JS_TESTS {
bar: string;
readonly baz: string;
bay(): string;
readonly __doNotUseIt: __doNotImplementIt;
readonly __doNotUseOrImplementIt: {
readonly "foo.I3": unique symbol;
};
}
function getI3(): foo.I3;
function getA(): foo.I3;
@@ -56,7 +56,7 @@ declare namespace JS_TESTS {
abstract set bar(value: string);
abstract get baz(): string;
abstract bay(): string;
readonly __doNotUseIt: __doNotImplementIt;
readonly __doNotUseOrImplementIt: foo.I3["__doNotUseOrImplementIt"];
}
class B2 extends foo.A2 {
constructor();
@@ -98,7 +98,7 @@ declare namespace JS_TESTS {
get name(): "EC1" | "EC2" | "EC3";
get ordinal(): 0 | 1 | 2;
abstract get baz(): string;
readonly __doNotUseIt: __doNotImplementIt;
readonly __doNotUseOrImplementIt: foo.I3["__doNotUseOrImplementIt"];
}
}
}
@@ -1,6 +1,4 @@
type Nullable<T> = T | null | undefined
declare const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
export namespace foo {
const prop: number;
class C {
@@ -1,7 +1,5 @@
declare namespace JS_TESTS {
type Nullable<T> = T | null | undefined
const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
namespace foo {
const prop: number;
class C {
@@ -1,6 +1,4 @@
type Nullable<T> = T | null | undefined
declare const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
export namespace foo {
const prop: number;
class C {
@@ -1,7 +1,5 @@
declare namespace JS_TESTS {
type Nullable<T> = T | null | undefined
const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
namespace foo.bar.baz {
class C1 {
constructor(value: string);
@@ -1,7 +1,5 @@
declare namespace JS_TESTS {
type Nullable<T> = T | null | undefined
const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
namespace foo {
const _any: any;
const _throwable: Error;
@@ -1,7 +1,5 @@
declare namespace JS_TESTS {
type Nullable<T> = T | null | undefined
const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
namespace foo {
interface ExportedInternalInterface {
}
@@ -1,7 +1,5 @@
declare namespace JS_TESTS {
type Nullable<T> = T | null | undefined
const __doNotImplementIt: unique symbol
type __doNotImplementIt = typeof __doNotImplementIt
interface publicInterface {
}
const publicVal: number;