TypeScript 编译为单个 JS 文件 [英] TypeScript compiling as a single JS file

查看:59
本文介绍了TypeScript 编译为单个 JS 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于 TypeScript 的测试项目,代码可以在这里找到.

I have a test project on TypeScript, code can found here.

当我使用 VS2012 创建新项目时,会创建一个 app.ts 文件.当我更改链接显示的内容并添加名为 GameModule 的新模块时,出现编译错误.当我删除 app.ts 并创建 Main.ts 时,一切都编译正常,但有一个问题 - 只有 Main.ts编译为 Main.jsGameModule.ts 保持未编译状态.

When I'm creating new project with VS2012, an app.ts file is created. When I'm changing it's content as shown by the link and adding new module called GameModule, I'm getting compile error. When I'm deleting app.ts and creating Main.ts instead, everything compiling fine, but there is a problem - only Main.ts is compiled to Main.js, and GameModule.ts stays uncompiled.

如何让编译器将所有代码合并到一个 JS 中?

How can I make compiler to merge all the code in one JS?

推荐答案

你必须使用编译器的命令行参数

You have to use command line arguments of compiler

--outFile FILE 连接输出到单个文件

 tsc --outFile modules.js main.ts app.ts

这篇关于TypeScript 编译为单个 JS 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆