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

Require that implemented method signature will be identical to interface/base #548

Closed
eladb opened this issue Jun 24, 2019 · 2 comments
Closed
Assignees
Labels
bug This issue is a bug. needs-reproduction This issue needs reproduction. p1

Comments

@eladb
Copy link
Contributor

eladb commented Jun 24, 2019

Repro:

export interface MyInterface {
  foo(bar: string): void;
}

export class MyClass implements MyInterface {
  foo(bar?: string): void;
}

This will succeed in typescript but fail in languages like Java. jsii should not allow it.

eladb pushed a commit to aws/aws-cdk that referenced this issue Jun 24, 2019
Additional fixes like #3036

Options are now not required in onXxx methods, but the interfaces where not updated to that end.

Related #2921
Root cause: aws/jsii#548
@SomayaB SomayaB added the bug This issue is a bug. label Nov 18, 2019
@RomainMuller RomainMuller added p2 p1 needs-reproduction This issue needs reproduction. and removed p2 labels Nov 21, 2019
@RomainMuller
Copy link
Contributor

Need to make sure this is still permitted.

@RomainMuller
Copy link
Contributor

Confirmed that jsii actively checks for this and prevents that:

error TS0: jsii-playground.MyCkass#foo changes the optionality of paramerter _bar when implementing jsii-playground.IMyInterface (expected false, found true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-reproduction This issue needs reproduction. p1
Projects
None yet
Development

No branches or pull requests

3 participants