TypeScript Version: 3.8.0-dev.20191119 (same result with 3.7.2 as well)
Search Terms: types checkJS
Code
{
"dependencies": {
"humane-js": "3.2.2"
},
"devDependencies": {
"@types/humane-js": "3.2.0",
"typescript": "3.8.0-dev.20191119"
}
}
// typescript.ts
import humane from 'humane-js';
humane.timeout = 4000;
export const notifyInfo = humane.spawn({ addnCls: 'humane-info' });
// javascript.js (same code than typescript.ts)
import humane from 'humane-js';
humane.timeout = 4000;
export const notifyInfo = 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).
TypeScript Version: 3.8.0-dev.20191119 (same result with 3.7.2 as well)
Search Terms: types checkJS
Code
{ "dependencies": { "humane-js": "3.2.2" }, "devDependencies": { "@types/humane-js": "3.2.0", "typescript": "3.8.0-dev.20191119" } }Expected behavior:
Running both
tsc --noEmit --esModuleInterop typescript.tsandtsc --noEmit --esModuleInterop --allowJS --checkJS javascript.jssucceed.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 thespawnmethod name gets caught)It would be great if
--esModuleInteropcould work when using tsc to check JS code, to allow using it to check webpack projects (which have such interop loading of JS modules).