TSConfig
moduleDetection
This setting controls how TypeScript determines whether a file is a script or a module.
There are three choices:
-
"auto"
(default) - TypeScript will not only look for import and export statements, but it will also check whether the"type"
field in apackage.json
is set to"module"
when running withmodule
:nodenext
ornode16
, and check whether the current file is a JSX file when running underjsx
:react-jsx
. -
"legacy"
- The same behavior as 4.6 and prior, usings import and export statements to determine whether a file is a module. -
"force"
- Ensures that every non-declaration file is treated as a module.