tsconfig.json的目的是什么?

时间:2020-12-12 23:37:54

I was reading angular2 referrences and found this tsconfig.json. I would like to know what the following parameters mean?

我正在阅读angular2 referrences并找到了这个tsconfig.json。我想知道以下参数是什么意思?

{
    "compilerOptions": {
    "target": "es5",
    "module": "system",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
    },
    "exclude": [
    "node_modules"
    ]
}

4 个解决方案

#1


16  

The tsconfig.json file corresponds to the configuration of the TypeScript compiler (tsc).

tsconfig.json文件对应于TypeScript编译器(tsc)的配置。

These links could give you details about these attributes:

这些链接可以提供有关这些属性的详细信息:

Here are some hints:

以下是一些提示:

  • target: the language used for the compiled output
  • target:用于编译输出的语言
  • module: the module manager used in the compiled output. system is for SystemJS, commonjs for CommonJS.
  • module:编译输出中使用的模块管理器。 system用于SystemJS,CommonJS的commonjs。
  • moduleResolution: the strategy used to resolve module declaration files (.d.ts files). With the node approach, they are loaded from the node_modules folder like a module (require('module-name'))
  • moduleResolution:用于解析模块声明文件(.d.ts文件)的策略。使用节点方法,它们从node_modules文件夹加载,如模块(require('module-name'))
  • sourceMap: generate or not source map files to debug directly your application TypeScript files in the browser,
  • sourceMap:生成或不生成源映射文件,直接在浏览器中调试应用程序TypeScript文件,
  • emitDecoratorMetadata: emit or not design-type metadata for decorated declarations in source,
  • emitDecoratorMetadata:发出或不发送源中装饰声明的设计类型元数据,
  • experimentalDecorators: enables or not experimental support for ES7 decorators,
  • experimentalDecorators:是否支持ES7装饰器的实验支持,
  • removeComments: remove comments or not
  • removeComments:删除评论与否
  • noImplicitAny: allow or not the use of variables / parameters without types (implicit)
  • noImplicitAny:允许或不允许使用不带类型的变量/参数(隐式)

#2


4  

tsconfig.json signifies the directory in which it is kept is the root of TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project.

tsconfig.json表示保存它的目录是TypeScript项目的根目录。 tsconfig.json文件指定编译项目所需的根文件和编译器选项。

The compiler is expected to execute as per the configurations mentioned:

期望编译器按照上述配置执行:

"target": "es5" => will compile the es6 to es5 so that it is compatible browsers.

“target”:“es5”=>将es6编译为es5,使其成为兼容的浏览器。

"module": "system" => specifies the module code generations (commonjs', 'amd', 'system', 'umd', 'es6' etc)

“module”:“system”=>指定模块代码生成(commonjs','amd','system','umd','es6'等)

"moduleResolution": "node" => Determine how modules get resolved

“moduleResolution”:“node”=>确定如何解析模块

"sourceMap": true => Generates corresponding ‘.map’ file so that it can be used in the production code for debugging.

“sourceMap”:true =>生成相应的“.map”文件,以便可以在生产代码中用于调试。

"removeComments": false => Remove all comments except copy-right header comments beginning with /*!

“removeComments”:false =>删除除以/ *开头的复制右侧标题注释之外的所有注释!

"noImplicitAny": false => Raise error on expressions and declarations with an implied ‘any’ type.

“noImplicitAny”:false =>使用隐含的“any”类型提高表达式和声明的错误。

If the "exclude" property is specified, the compiler includes all TypeScript (*.ts or *.tsx) files in the containing directory and subdirectories except for those files or folders that are excluded.

如果指定了“exclude”属性,则编译器将包含所有包含目录和子目录中的TypeScript(* .ts或* .tsx)文件,但排除这些文件或文件夹除外。

#3


1  

tsconfig file indicates the project as typescript project and it includes options on how the typescript files to be compiled. For details check the site https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

tsconfig文件将项目指示为typescript项目,它包含有关如何编译typescript文件的选项。有关详细信息,请访问网站https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

#4


0  

Already there are lot of answers, but I would like to add one more point as why tsconfig required. As per angular docs

已经有很多答案,但我想补充一点,为什么需要tsconfig。根据角度文档

TypeScript is a primary language for Angular application development. It is a superset of JavaScript with design-time support for type safety and tooling.

TypeScript是Angular应用程序开发的主要语言。它是JavaScript的超集,具有对类型安全和工具的设计时支持。

Browsers can't execute TypeScript directly. Typescript must be "transpiled" into JavaScript using the tsc compiler, which requires some configuration.

浏览器无法直接执行TypeScript。必须使用tsc编译器将Typescript“转换”为JavaScript,这需要一些配置。

Typically, you add a TypeScript configuration file called tsconfig.json to your project to guide the compiler as it generates JavaScript files.

通常,您将名为tsconfig.json的TypeScript配置文件添加到项目中,以指导编译器生成JavaScript文件。

For more information https://angular.io/guide/typescript-configuration

有关更多信息,请访问https://angular.io/guide/typescript-configuration

#1


16  

The tsconfig.json file corresponds to the configuration of the TypeScript compiler (tsc).

tsconfig.json文件对应于TypeScript编译器(tsc)的配置。

These links could give you details about these attributes:

这些链接可以提供有关这些属性的详细信息:

Here are some hints:

以下是一些提示:

  • target: the language used for the compiled output
  • target:用于编译输出的语言
  • module: the module manager used in the compiled output. system is for SystemJS, commonjs for CommonJS.
  • module:编译输出中使用的模块管理器。 system用于SystemJS,CommonJS的commonjs。
  • moduleResolution: the strategy used to resolve module declaration files (.d.ts files). With the node approach, they are loaded from the node_modules folder like a module (require('module-name'))
  • moduleResolution:用于解析模块声明文件(.d.ts文件)的策略。使用节点方法,它们从node_modules文件夹加载,如模块(require('module-name'))
  • sourceMap: generate or not source map files to debug directly your application TypeScript files in the browser,
  • sourceMap:生成或不生成源映射文件,直接在浏览器中调试应用程序TypeScript文件,
  • emitDecoratorMetadata: emit or not design-type metadata for decorated declarations in source,
  • emitDecoratorMetadata:发出或不发送源中装饰声明的设计类型元数据,
  • experimentalDecorators: enables or not experimental support for ES7 decorators,
  • experimentalDecorators:是否支持ES7装饰器的实验支持,
  • removeComments: remove comments or not
  • removeComments:删除评论与否
  • noImplicitAny: allow or not the use of variables / parameters without types (implicit)
  • noImplicitAny:允许或不允许使用不带类型的变量/参数(隐式)

#2


4  

tsconfig.json signifies the directory in which it is kept is the root of TypeScript project. The tsconfig.json file specifies the root files and the compiler options required to compile the project.

tsconfig.json表示保存它的目录是TypeScript项目的根目录。 tsconfig.json文件指定编译项目所需的根文件和编译器选项。

The compiler is expected to execute as per the configurations mentioned:

期望编译器按照上述配置执行:

"target": "es5" => will compile the es6 to es5 so that it is compatible browsers.

“target”:“es5”=>将es6编译为es5,使其成为兼容的浏览器。

"module": "system" => specifies the module code generations (commonjs', 'amd', 'system', 'umd', 'es6' etc)

“module”:“system”=>指定模块代码生成(commonjs','amd','system','umd','es6'等)

"moduleResolution": "node" => Determine how modules get resolved

“moduleResolution”:“node”=>确定如何解析模块

"sourceMap": true => Generates corresponding ‘.map’ file so that it can be used in the production code for debugging.

“sourceMap”:true =>生成相应的“.map”文件,以便可以在生产代码中用于调试。

"removeComments": false => Remove all comments except copy-right header comments beginning with /*!

“removeComments”:false =>删除除以/ *开头的复制右侧标题注释之外的所有注释!

"noImplicitAny": false => Raise error on expressions and declarations with an implied ‘any’ type.

“noImplicitAny”:false =>使用隐含的“any”类型提高表达式和声明的错误。

If the "exclude" property is specified, the compiler includes all TypeScript (*.ts or *.tsx) files in the containing directory and subdirectories except for those files or folders that are excluded.

如果指定了“exclude”属性,则编译器将包含所有包含目录和子目录中的TypeScript(* .ts或* .tsx)文件,但排除这些文件或文件夹除外。

#3


1  

tsconfig file indicates the project as typescript project and it includes options on how the typescript files to be compiled. For details check the site https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

tsconfig文件将项目指示为typescript项目,它包含有关如何编译typescript文件的选项。有关详细信息,请访问网站https://www.typescriptlang.org/docs/handbook/tsconfig-json.html

#4


0  

Already there are lot of answers, but I would like to add one more point as why tsconfig required. As per angular docs

已经有很多答案,但我想补充一点,为什么需要tsconfig。根据角度文档

TypeScript is a primary language for Angular application development. It is a superset of JavaScript with design-time support for type safety and tooling.

TypeScript是Angular应用程序开发的主要语言。它是JavaScript的超集,具有对类型安全和工具的设计时支持。

Browsers can't execute TypeScript directly. Typescript must be "transpiled" into JavaScript using the tsc compiler, which requires some configuration.

浏览器无法直接执行TypeScript。必须使用tsc编译器将Typescript“转换”为JavaScript,这需要一些配置。

Typically, you add a TypeScript configuration file called tsconfig.json to your project to guide the compiler as it generates JavaScript files.

通常,您将名为tsconfig.json的TypeScript配置文件添加到项目中,以指导编译器生成JavaScript文件。

For more information https://angular.io/guide/typescript-configuration

有关更多信息,请访问https://angular.io/guide/typescript-configuration