aws / jsii-compiler

The jsii compiler for TypeScript
https://aws.github.io/jsii/
Apache License 2.0
29 stars 15 forks source link

Disallow argument mismatch between interface and implementation #1320

Open iliapolo opened 2 months ago

iliapolo commented 2 months ago

Currently, the compiler will allow the following program:

export interface IAdder {
  add(a: number, b: number): number;
}

export class Adder implements IAdder {
  public add(a1: number, b1: number): number {
    return a1 + b1;
  }
}

Notice the argument names in Adder.add are different from IAdder.add.

This results in an incompatibility between the IAdder interface and the Adder class in python. See:

We should have the compiler enforce that functions in implementations (or subclasses) use the same argument names as the parent.

Notes

iliapolo commented 2 months ago

We should only pick this up after a decision has been made with respect to https://github.com/aws/jsii/issues/4541#issuecomment-2337483516