You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// javascript.js (same code than typescript.ts)importhumanefrom'humane-js';humane.timeout=4000;exportconstnotifyInfo=humane.spawn({addnCls: 'humane-info'});
Expected behavior:
Running both tsc --noEmit --esModuleInterop typescript.ts and tsc --noEmit --esModuleInterop --allowJS --checkJS javascript.js succeed.
Actual behavior:
Type-checking for the Typescript file succeeds. But type-checking for the javascript files fails with this error:
javascript.js:5:34 - error TS2339: Property 'spawn' does not exist on type 'typeof humane'.
5 export const notifyInfo = humane.spawn({ addnCls: 'humane-info' });
~~~~~
Found 1 error.
Note that if I change my JS file to use a CommonJS require call rather than an ES import and then run tsc --noEmit --allowJS --checkJS javascript.js, tsc will properly identify the type of humane (type-checking succeeds on this code, and introducing a typo in the spawn method name gets caught)
It would be great if --esModuleInterop could work when using tsc to check JS code, to allow using it to check webpack projects (which have such interop loading of JS modules).
The text was updated successfully, but these errors were encountered:
TypeScript Version: 3.8.0-dev.20191119 (same result with 3.7.2 as well)
Search Terms: types checkJS
Code
Expected behavior:
Running both
tsc --noEmit --esModuleInterop typescript.ts
andtsc --noEmit --esModuleInterop --allowJS --checkJS javascript.js
succeed.Actual behavior:
Type-checking for the Typescript file succeeds. But type-checking for the javascript files fails with this error:
Note that if I change my JS file to use a CommonJS require call rather than an ES import and then run
tsc --noEmit --allowJS --checkJS javascript.js
, tsc will properly identify the type ofhumane
(type-checking succeeds on this code, and introducing a typo in thespawn
method name gets caught)It would be great if
--esModuleInterop
could work when using tsc to check JS code, to allow using it to check webpack projects (which have such interop loading of JS modules).The text was updated successfully, but these errors were encountered: