-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jsii): detect double interface member declarations (#360)
In C# it's prohibited to declare an interface member that also exists in an inherited interface. Have jsii detect this illegal pattern. Strictly speaking, this only true if we don't overload, but since we don't support overloading anyway we just check on the member names, not the types. Fixes #340.
- Loading branch information
Showing
5 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
packages/jsii/test/negatives/neg.double-interface-members-deeper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
///!MATCH_ERROR: Interface declares same member as inherited interface: foo | ||
|
||
export interface IA { | ||
foo(): void; | ||
} | ||
|
||
export interface IB extends IA { | ||
bar(): void; | ||
} | ||
|
||
export interface IC extends IB { | ||
foo(): void; | ||
} | ||
|
||
|
9 changes: 9 additions & 0 deletions
9
packages/jsii/test/negatives/neg.double-interface-members-method.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
///!MATCH_ERROR: Interface declares same member as inherited interface: foo | ||
|
||
export interface IA { | ||
foo(): void; | ||
} | ||
export interface IB extends IA { | ||
foo(): void; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
///!MATCH_ERROR: Interface declares same member as inherited interface: foo | ||
|
||
export interface A { | ||
foo: number; | ||
} | ||
export interface B extends A { | ||
foo: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters