Understanding “target” and “module” in tsconfig

后端 未结 2 1015
小蘑菇
小蘑菇 2020-12-13 11:38

Below is my tsconfig.json file where I have set target to es5 and module to es6

{
   "compilerOptions": {
            


        
2条回答
  •  没有蜡笔的小新
    2020-12-13 12:26

    To supplement the previous answer, in 2020 there are 4 TS config options that define the module resolution and compilation output:

    • module.
    • target.
    • lib.
    • moduleResolution.

    The first 3 affect your output, while the latter affects the way the compiler searches for your modules to resolve them and bundle.

    Here's a great and concise article about these options: Typescript confusion: tsconfig.json module, moduleResolution, target & lib explained | by Tom Medema | Medium.

    Additionally, a doc about module resolution: TypeScript: Handbook - Module Resolution.

提交回复
热议问题