Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: copy non-hidden bases when erasing hidden interfaces #392

Merged
merged 4 commits into from
Mar 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1424,3 +1424,55 @@ export class ImplementsPrivateInterface implements IPrivateInterface {
export interface ExtendsPrivateInterface extends IPrivateInterface {
moreThings: string[];
}

//
// hidden (private/internal) base interface erasure will copy non-hidden bases from
// hidden to consuming type.
//

export interface IAnotherPublicInterface {
a: string;

}

/** @internal */
export interface IAnotherInternalInterface extends IAnotherPublicInterface {
b: string;
}

export interface INonInternalInterface extends IAnotherInternalInterface {
c: string;
}

/** @internal */
export interface IInternalInterfaceThatExtendsTheNonInternalOne extends INonInternalInterface {
d: string;
}

interface IPrivateInterfaceThatExtendsTheNonInternalOne extends INonInternalInterface {
e: string;
}

export class ClassThatImplementsTheInternalInterface implements IInternalInterfaceThatExtendsTheNonInternalOne, INonInternalInterface {
public a = 'a';
public b = 'b';
public c = 'c';
public d = 'd';
}

export class ClassThatImplementsThePrivateInterface implements IPrivateInterfaceThatExtendsTheNonInternalOne {
public a = 'a';
public b = 'b';
public c = 'c';
public e = 'e';
}

export class ConsumersOfThisCrazyTypeSystem {
public consumeAnotherPublicInterface(obj: IAnotherPublicInterface) {
return obj.a;
}

public consumeNonInternalInterface(obj: INonInternalInterface): any {
return { a: obj.a, b: obj.b, c: obj.c };
}
}
168 changes: 167 additions & 1 deletion packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,98 @@
}
]
},
"jsii-calc.ClassThatImplementsTheInternalInterface": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.ClassThatImplementsTheInternalInterface",
"initializer": {
"initializer": true
},
"interfaces": [
{
"fqn": "jsii-calc.INonInternalInterface"
}
],
"kind": "class",
"name": "ClassThatImplementsTheInternalInterface",
"properties": [
{
"name": "a",
"overrides": {
"fqn": "jsii-calc.IAnotherPublicInterface"
},
"type": {
"primitive": "string"
}
},
{
"name": "b",
"type": {
"primitive": "string"
}
},
{
"name": "c",
"overrides": {
"fqn": "jsii-calc.INonInternalInterface"
},
"type": {
"primitive": "string"
}
},
{
"name": "d",
"type": {
"primitive": "string"
}
}
]
},
"jsii-calc.ClassThatImplementsThePrivateInterface": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.ClassThatImplementsThePrivateInterface",
"initializer": {
"initializer": true
},
"interfaces": [
{
"fqn": "jsii-calc.INonInternalInterface"
}
],
"kind": "class",
"name": "ClassThatImplementsThePrivateInterface",
"properties": [
{
"name": "a",
"overrides": {
"fqn": "jsii-calc.IAnotherPublicInterface"
},
"type": {
"primitive": "string"
}
},
{
"name": "b",
"type": {
"primitive": "string"
}
},
{
"name": "c",
"overrides": {
"fqn": "jsii-calc.INonInternalInterface"
},
"type": {
"primitive": "string"
}
},
{
"name": "e",
"type": {
"primitive": "string"
}
}
]
},
"jsii-calc.ClassWithMutableObjectLiteralProperty": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.ClassWithMutableObjectLiteralProperty",
Expand Down Expand Up @@ -1140,6 +1232,45 @@
],
"name": "Constructors"
},
"jsii-calc.ConsumersOfThisCrazyTypeSystem": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.ConsumersOfThisCrazyTypeSystem",
"initializer": {
"initializer": true
},
"kind": "class",
"methods": [
{
"name": "consumeAnotherPublicInterface",
"parameters": [
{
"name": "obj",
"type": {
"fqn": "jsii-calc.IAnotherPublicInterface"
}
}
],
"returns": {
"primitive": "string"
}
},
{
"name": "consumeNonInternalInterface",
"parameters": [
{
"name": "obj",
"type": {
"fqn": "jsii-calc.INonInternalInterface"
}
}
],
"returns": {
"primitive": "any"
}
}
],
"name": "ConsumersOfThisCrazyTypeSystem"
},
"jsii-calc.DefaultedConstructorArgument": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.DefaultedConstructorArgument",
Expand Down Expand Up @@ -1611,6 +1742,21 @@
],
"name": "GreetingAugmenter"
},
"jsii-calc.IAnotherPublicInterface": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.IAnotherPublicInterface",
"kind": "interface",
"name": "IAnotherPublicInterface",
"properties": [
{
"abstract": true,
"name": "a",
"type": {
"primitive": "string"
}
}
]
},
"jsii-calc.IFriendlier": {
"assembly": "jsii-calc",
"docs": {
Expand Down Expand Up @@ -1750,6 +1896,26 @@
],
"name": "IInterfaceWithOptionalMethodArguments"
},
"jsii-calc.INonInternalInterface": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.INonInternalInterface",
"interfaces": [
{
"fqn": "jsii-calc.IAnotherPublicInterface"
}
],
"kind": "interface",
"name": "INonInternalInterface",
"properties": [
{
"abstract": true,
"name": "c",
"type": {
"primitive": "string"
}
}
]
},
"jsii-calc.IPrivatelyImplemented": {
"assembly": "jsii-calc",
"fqn": "jsii-calc.IPrivatelyImplemented",
Expand Down Expand Up @@ -4083,5 +4249,5 @@
}
},
"version": "0.7.15",
"fingerprint": "iMxRj3lsHKNzSiBrjCyBH6Pp7Uvo+1Sxh/jN3hW+3nA="
"fingerprint": "y7h6OQBzbQrvU43LHTizXl12OUAEOpXhqD02OJfmhWQ="
}
Loading