简体   繁体   English

使用 tsc 将 .json 文件转换为 .ts 文件

[英]Converting .json files to .ts files using tsc

My express folder in the react project (made with create-react-app) has .ts files and .json files.我在 react 项目中的 express 文件夹(使用 create-react-app 制作)有.ts文件和.json文件。 I want to convert .ts files to .js files internally using the tsc tool.我想在内部使用 tsc 工具将.ts文件转换为.js文件。 As I want to build my express folder I need to convert all the files in the express folder to .js files.由于我想构建我的 express 文件夹,我需要将 express 文件夹中的所有文件转换为.js文件。 Now, I can convert the .ts files to .js files and store it into a different folder using the command tsc --outDir dist src/**/* .现在,我可以使用命令tsc --outDir dist src/**/*.ts文件转换为.js文件并将其存储到不同的文件夹中。 But this command throws an error on files which are not .ts.但是这个命令会在不是 .ts 的文件上引发错误。 How can I convert all the files (including the ones which are not .ts, specifically .json files) using an internal tool/package such as tsc?如何使用 tsc 等内部工具/包转换所有文件(包括不是 .ts 的文件,特别是 .json 文件)?

Stuck on this issue for quite sometime.卡在这个问题上很长一段时间。 Any help or directions would be helpful.任何帮助或指示都会有所帮助。

您可以将 'include:[yourfiledir/**/*.js]' 插入 'tsconfig.json'

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

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