[英]Typescript split solution into several projects
I used ScriptSharp before it was frozen. 在冻结之前我使用了ScriptSharp。 Since TypeScript is a developing OOP language I decided to try it.
由于TypeScript是一种正在开发的OOP语言,我决定尝试它。 I use visual studio (if it matters).
我使用visual studio(如果重要的话)。 I have troubles making simple things I used to do in ScriptSharp.
我在ScriptSharp中制作简单的事情我遇到了麻烦。 I didn't expect it would be that difficult.
我没想到会那么困难。 What I want to do:
我想做的事:
Can you give me some guide how to make it work or sample? 你能给我一些如何使其工作或样品的指南吗? Thanks.
谢谢。
UPDATE: What's for I can add reference to another typescript project? 更新:什么是我可以添加对另一个打字稿项目的引用? It would be great if output of referenced project was copied to that project.
如果将引用项目的输出复制到该项目,那将是很好的。
Rather than having assemblies and modules, you have modules that can be organised into namespace-like hierarchies: 您可以将模块组织成类似命名空间的层次结构,而不是拥有程序集和模块:
Internal Module Example: 内部模块示例:
module AssemblyA {
export module ModuleA {
export class Example {
}
}
export module ModuleB {
export class Example {
}
}
}
var x = new AssemblyA.ModuleA.Example();
var y = new AssemblyA.ModuleB.Example();
You can also define these internal modules across multiple files... 您还可以跨多个文件定义这些内部模块......
modulea.ts modulea.ts
module AssemblyA {
export module ModuleA {
export class Example {
}
}
}
moduleb.ts moduleb.ts
///<reference path="./modulea.ts" />
module AssemblyA {
export module ModuleB {
export class Example {
}
}
}
app.ts app.ts
///<reference path="./modulea.ts" />
///<reference path="./moduleb.ts" />
var x = new AssemblyA.ModuleA.Example();
var y = new AssemblyA.ModuleB.Example();
And if you want to write really large applications, you can use external modules (where the file represents the module). 如果您想编写非常大的应用程序,可以使用外部模块(文件代表模块)。
assemblya/modulea.ts assemblya / modulea.ts
export class Example {
}
assemblya/moduleb.ts assemblya / moduleb.ts
export class Example {
}
app.ts app.ts
import ModuleA = require('./assemblya/modulea');
import ModuleA = require('./assemblya/modulea');
var x = new ModuleA.Example();
var y = new ModuleB.Example();
I found a workaround for my problem: 我找到了解决问题的方法:
In project AssemblyA: 在项目AssemblyA中:
In project AssemblyB: 在项目AssemblyB中:
///<reference path="../AssemblyA/AssemblyA.d.ts" />
///<reference path="../AssemblyA/AssemblyA.d.ts" />
<script src="AssemblyA.js"></script>
<script src="AssemblyA.js"></script>
In project B you can use any namespace aliases (for example: import AssemblyANS2 = AssemblyA.NS2;) or fully qualified name. 在项目B中,您可以使用任何名称空间别名(例如:import AssemblyANS2 = AssemblyA.NS2;)或完全限定名称。 Put classes in different files, Use same module name and there is no need to refer to ts files.
将类放在不同的文件中,使用相同的模块名称,不需要引用ts文件。
What I didn't like is that referencing project doesn't make any sense, but I wanted steps 1-2-3-4 to be done automatically after adding reference. 我不喜欢的是引用项目没有任何意义,但我希望在添加引用后自动完成步骤1-2-3-4。 Also "Redirect javascript output to directory" setting doesn't work when "Combine javascript output into one file" is specified.
当指定“将javascript输出合并为一个文件”时,“将javascript输出重定向到目录”设置也不起作用。 It's also weird that I can specify file path in second options.
我可以在第二个选项中指定文件路径也很奇怪。 I expected these settings to be combined with Path.Combine.
我希望这些设置与Path.Combine结合使用。 Maybe my solution is not ideal, but it's exactly what I need.
也许我的解决方案并不理想,但这正是我所需要的。 Feel free to suggest better idea.
随意提出更好的主意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.