简体   繁体   中英

Understanding .tsconfig file

Being a beginner, I am unable to comprehend the significance of some terms, despite going through documentation.

In my .tsconfig file I have

emitDecoratorMetadata

sourceMap

esModuleInterop -> Allow default imports from modules with no default export. This does not affect code emit, just typechecking. Can someone please make the above definition as humanly comprehensible as possible? Does this mean we can just import and not export?

For example, the definition for emitDecoratorMetadata in one of the answers says

emit or not design-type metadata for decorated declarations in source

What does decorated declarations in source mean? Also, if someone could explain sourceMap in slightly more human terms, that would be so helpful.

Update: @Antonis Wrote an amazing answer still the last part looks vague. I created a separate post here:

Understanding esModuleInterop in tsconfig file Resources I went through:

  1. https://www.typescriptlang.org/docs/handbook/compiler-options.html
  2. https://basarat.gitbooks.io/typescript/docs/project/tsconfig.html
  3. what is the purpose of tsconfig.json?

emitDecoratorMetadata - In Angular for example we got the @Injectable , @Component , @NgModule decorators.

These decorators enable the class to emit metadata that carry information required, in order for the Angular to understand the kind of dependencies this class needs and utilizes in it's constructor as well as how to handle this class later at runtime

Check this answer here as well.

sourceMap - Source maps carry the information of the original source code. We need this kind of maps when the browser is running the minified, obscured and bundled code. The maps reflect the original code in the bundled one so we can debug it later

esModuleInterop - First of all read about CommonJS Modules and ESModules. Secondly it pretty much means that in case there isn't one default export from the module, you still can default import something from that module

The offical docs might help understand the .tsconfig file in its entirety.

The presence of a tsconfig.json file in a directory indicates that the directory is the root of a TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project.

More information here: tsconfig.json

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM