TypeScript Version: Version 2.7.0-dev.20171109
Code
typeArgs<Sextendsstring,Nextendsstring>=Record<S,string>&Record<N,number>declarefunctionf1<Sextendsstring,Nextendsstring>(strs: S[],nums: N[],fun: (args: Args<S,N>)=>void): voiddeclarefunctiontakesNum(args: {a: number}): voiddeclarefunctiontakesOptionalNum(args: {a?: number}): voidf1(["a"],[],takesNum)// *** unexpectedly compiles despite incompatibility of "a" ***f1(["a"],["b"],takesNum)// Now correctly errors because of incompatibility of "a"f1(["a"],[],takesOptionalNum)// *** unexpectedly compiles despite incompatibility of "a" ***f1(["a"],["b"],takesOptionalNum)// Now correctly errors because of incompatibility of "a"Expected behavior:
All calls to f1 should error because takesNum and takesOptionalNum expect a to be a number but it will actually be a string.
Actual behavior:
It only errors if the second argument to f1 is not empty.
Also the first case shown above: f1(["a"], [], takesNum) actually errored as expected as recently as last week(I believe I was on 2.7.0-dev.20171031), it was only the optional case that unexpectedly compiled. I was about to open this for just the optional case when I checked the latest typescript version and noticed the first case started being affected also.
TypeScript Version: Version 2.7.0-dev.20171109
Code
Expected behavior:
All calls to
f1should error becausetakesNumandtakesOptionalNumexpectato be a number but it will actually be a string.Actual behavior:
It only errors if the second argument to f1 is not empty.
Also the first case shown above:
f1(["a"], [], takesNum)actually errored as expected as recently as last week(I believe I was on 2.7.0-dev.20171031), it was only the optional case that unexpectedly compiled. I was about to open this for just the optional case when I checked the latest typescript version and noticed the first case started being affected also.