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
{{ message }}
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
It is a bit confusing, because "must" in this case means "really should (but we'll often fix your mistake if you do it wrong)".
The code import * as module from 'module' actually means "import the namespace in 'module', and refer to that namespace as module in the file". Such a namespace is not callable/constructable according to the ECMAscript spec. However, lots of TypeScript code out there uses this incorrect code.
So if your module target is CommonJS, TypeScript will fix it for you, as if you wrote import module = require("module"). If your module is an ES module, however, TypeScript won't fix it for you, and the code will fail. So as the NodeJS ecosystem is slowly moving to ES modules, at some point your "working" code could start failing if you use the incorrect syntax.
https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require
I'm confused about this statement, because
import * as module from 'module'
also works, right?/cc @DanielRosenwasser
The text was updated successfully, but these errors were encountered: