#Is there a difference between typescript's import syntax and the ESM standard?

6 messages · Page 1 of 1 (latest)

shut pond
#

I'm curious to know how typescript's import syntax and the ESM spec would overlap on a venn diagram. If they don't completely overlap, what are the differences between the two?

shrewd minnow
#

typescript has import = and export = to model how cjs or similar systems work more closely

#

it also has type-level imports

#

ts imports have to model both esm and cjs as well as type stuff so it's a superset of esm

shut pond
#

@shrewd minnow Sorry for the late reply. First of all, thanks for the information! Are there lots of little things like this or is your response pretty comprehensive?

shy brook
#

I believe that TS's (ordinary) import and export is the same, but resolution is not. The resolution will depend on factors like moduleResolution setting, whether TS is compiling to ESM or CJS, and any paths overrides.