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
Deno doesn't support "allowSyntheticDefaultImports" compiler option which means a lot of npm dependencies that ship types won't typecheck properly
#17058
Closed
itsdouges opened this issue
Dec 15, 2022
· 3 comments
Hello! There's quite a few npm dependences that have typedefs for default exports that look like, well, a default export! Currently in Deno it results in the following error:
This expression is not callable.
As more folk start using Deno they're going to run into this problem, and it'll be a friction point that ideally shouldn't exist.
It's expected. We initially experimented with something to make this work, but now for node compat in Deno (which is always ESM) we decided to align with and follow the same rules that Node does in an ES module importing CJS. As I mentioned in the linked issues, those packages runtime code does module.exports = ..., but then define that in their types as export default, when it should be export =.
The bottom line is those packages need to fix their incorrect type declarations anyway if they want it to work when being imported by a Node ES module and then it will also work in Deno. I'd recommend if you come across a package like that to submit a pull request to their repo to correct their declarations and make it work correctly in both Node and Deno. In the meantime, you can write code like the following to "fix" the package's incorrect types:
In TypeScript, the allowSyntheticDefaultImports works because it's not using ES modules under the hood and instead transpiling to require with some injected code.
Hello! There's quite a few npm dependences that have typedefs for default exports that look like, well, a default export! Currently in Deno it results in the following error:
As more folk start using Deno they're going to run into this problem, and it'll be a friction point that ideally shouldn't exist.
Other related issues:
deno bench
fails when importingnpm:ioredis
on v1.27.0 #16475Can Deno support the
allowSyntheticDefaultImports
compiler option, or do something to transparently make this work?The text was updated successfully, but these errors were encountered: