Closed
Description
TypeScript Version: 3.4.0-dev.20190309
Search Terms: CallableFunction, call, bind, inference
Code
Promise.resolve.call(1) // Compiles without error, throws in runtime
Promise.resolve.call(Promise, 1); // Compile-time error, works fine in runtime
Expected behavior:
Promise.resolve.call(1)
should trigger a compile-time errorPromise.resolve.call(Promise, 1)
should compile
Actual behavior:
The situation is reversed. The one that works in runtime does not compile. The one that does compile throws a runtime error.
Promise.resolve.call(1)
compiles without error, throwsUncaught TypeError: PromiseResolve called on non-object
in runtimePromise.resolve.call(Promise, 1)
gives a compile-time error (Expected 1 arguments, but got 2.
), works fine in runtime (returns aPromise<number>
)
I'm using "lib": ["dom", "esnext"], "target: "es2015"
. Tested on Chrome 72.0.3626.121, V8 7.2.502.28.
Playground Link: The compile-time error is not there, but the runtime exception can be observed