Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Typescript 中是否有类似匿名模块的内容可以转换为以下内容?
(function(){ })()
没有替代方法可以做到这一点,但您仍然可以在 TypeScript 文件中使用该语法来使用立即执行的函数来确定您的内容范围。
(function(){ var myClass = new SomeModule.SomeClass(); })();
我希望在app.ts文件中经常看到这一点。
app.ts
如果您真的想在其中获得一些 TypeScript,可以将其缩短为:
() => { var x = 1; }();