This project is read-only.

Signature assignability and subtyping mismatch in Spec and compiler

Topics: Language Specification
Aug 26, 2013 at 7:28 PM
Edited Aug 26, 2013 at 7:30 PM
TypeScript spec says (3.8.2):
M is a non-specialized call or construct signature and S’ contains a call or construct signature N where, when substituting ‘Object’ for all type parameters declared by M and N (if any),
the number of non-optional parameters in N is less than or equal to that of M,


rest parameters correspond to an unbounded expansion of optional parameters of the rest parameter element type.

But actually compiler allows the next code:
class A {
    s(...p3) {

class B {
    s(p1, p2) {

var a : A;
var b : B;
a = b;
No error on a = b despite A.s has 0 non-optional parameters and B.x has 2 ones.

But if replace the class A with:
class A {
    s(p1?, p2?) {
that should be an equivalent by spec, the code above isn't compiled.
Aug 26, 2013 at 7:44 PM
Edited Aug 26, 2013 at 7:45 PM
Thanks, that does look incorrect. I've created a work item for this issue here.