简体   繁体   English

如何在angular2项目中创建tsconfig.json文件?

[英]How to create tsconfig.json file in angular2 project?

I have created one angular2 project using npm. 我用npm创建了一个angular2项目。 I was referring this link: Angular2 Tutorial 我指的是这个链接: Angular2 Tutorial

I succeessfully created the package.json file using npm init command. 我使用npm init命令成功创建了package.json文件。 But I didnt find any command to create tsconfig.json file. 但我没有找到任何创建tsconfig.json文件的命令。 I am not sure that should I create that file using command or using editor? 我不确定我应该使用命令还是使用编辑器创建该文件? Thanks in advance. 提前致谢。

使用init选项调用TypeScript编译器将在当前目录中创建新的tsconfig.json

tsc --init

To complement the Vadim's answer, the tsc command is available after having installed TypeScript: 为了补充Vadim的答案,安装TypeScript后可以使用tsc命令:

$ npm install -g typescript

You can also use some parameters with this comment: 您还可以在此评论中使用一些参数:

$ tsc --init --experimentalDecorators
      --moduleResolution node --target ES5
      --sourceMap --module system --removeComments

This way, you're very close to what Angular.io uses for this samples. 这样,您就非常接近Angular.io用于此示例的内容。

You can then remove the outDir and rootDir entries if not needed. 然后,如果不需要,您可以删除outDirrootDir条目。 Moreover an entry isn't generated this way. 此外,不会以这种方式生成条目。 You can add it manually in the generaed tsconfig.json file. 您可以在生成的tsconfig.json文件中手动添加它。

"emitDecoratorMetadata": true

Hope it helps you, Thierry 希望它对你有帮助,蒂埃里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 项目目录外的 tsconfig.json 文件 - tsconfig.json file outside of project directory 使用tsconfig.json的Visual Studio 2015,Typescript和angular2 - Visual Studio 2015, Typescript and angular2 with tsconfig.json 如何为 tsconfig.json 使用 CommonJS 文件? - How to use CommonJS file for tsconfig.json? 将 Angular 10 项目转换为 nativescript 共享项目时出现“无法解析 tsconfig.json 文件”错误 - “Can't parse tsconfig.json file” error when converting Angular 10 project to nativescript shared project 在没有 tsconfig.json 全局项目级别的情况下,打字稿文件在 vs2017 中自动创建 Javascript - Typescript file auto create Javascript in vs2017 without tsconfig.json globally project level Angular 中 tsconfig.json 文件中的 lib 数组中的 dom 是什么? - What is dom for in the lib array in the tsconfig.json file in Angular? 如何将tsconfig.json文件添加到Visual Studio 2015项目中以获取编译器选项? - How to add a tsconfig.json file to Visual Studio 2015 project for compiler options? 如何在具有多个 tsconfig.json 的项目中设置路径属性? - How to set paths property in a project with multiple tsconfig.json? 如何在升级期间告诉 Angular 12 我的 tsconfig.json 文件在哪里? - How do I tell Angular 12 during an upgrade where my tsconfig.json file is? 如何处理具有多个tsconfig.json文件的项目? - How to handle a project with multiple tsconfig.json files?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM