Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript:如何组织应用程序_Typescript - Fatal编程技术网

Typescript:如何组织应用程序

Typescript:如何组织应用程序,typescript,Typescript,有件事我想不通。我有这些类型脚本文件: // app.ts import {SomethingService} from "./something"; new SomethingService().yay(); - - //index.html 然后,我用:tsc app.TS--module amd--outFile app.js 但是,由于import语句,app.ts被视为一个模块,实际代码永远不会执行。警报永远不会弹出。如何确保app.ts中的代码被执行?因此,这里您需要告诉requ

有件事我想不通。我有这些类型脚本文件:

// app.ts
import {SomethingService} from "./something";
new SomethingService().yay();
-

-

//index.html
然后,我用:
tsc app.TS--module amd--outFile app.js


但是,由于import语句,app.ts被视为一个模块,实际代码永远不会执行。警报永远不会弹出。如何确保app.ts中的代码被执行?

因此,这里您需要告诉require.js来处理它

<script data-main="app.js" src="require.js"></script>


您是否尝试过从typescript而不是html引导它?我尝试过,但我遇到了与您不在此处导入angular相同的错误?///你说得对,我在例子里忘了。现在已添加。您现在可以引导应用程序了吗?如何导入app.ts文件?如果我将导出添加到app.ts,并尝试在main.ts中导入该导出,则该文件也会变成一个模块,并且不会执行-moduleceptionIt我仍然不清楚。。。你在这里定义什么文件?app.ts?本例中TodoCtrl来自何处?如果查看_all.ts,它将导入所有组件。Application.ts的顶部有这个///我以为外部模块解析应该替换///标记?
// index.html
<html>
<head>
<script src="require.js"></script>
<script src="app.js"></script>
</head>

<body>
</body>
</html>
<script data-main="app.js" src="require.js"></script>