【问题标题】:Why do we need _all.ts when using typescript with angularjs1.5?为什么我们在使用带有 angularjs1.5 的 typescript 时需要 _all.ts?
【发布时间】:2016-01-20 14:33:41
【问题描述】:

我正在尝试使用 AngularJSGrunt 在 Typescript 上进行 POC。我没有找到很多清楚解释该过程的文档。

我看到当我在_all.ts 中添加所有打字稿引用时,它就可以工作了。但我需要了解原因。谁解析_all.ts 使其工作?

文件夹结构 anggen -.tmp -app -blocks -common -images ... -styles -404.html -_all.ts -app.ts -favicon.ico -index.html -bower_components -node_modules -test -typings -.bowerrc -.editorconfig -.gitattributes -.gitignore -.jscsrc -.jshintrc -.travis.yml -.yo-rc.json -bower.json -Gruntfile.js -package.json -README.md -tsd.json -tslint.json

【问题讨论】:

  • 您能分享一下您的应用程序的结构吗?通常有一个正确定义的tsconfig.json就足够了,你有这样的文件吗?
  • 这可能是问题的一部分。还要检查@basarat 的答案。可能是您采用了一种较旧的方式来创建打字稿项目。 :)
  • 是否有任何链接指向使用 tsconfig.json 的新方式?
  • 另外,在文件夹中运行 tsc --init 应该会创建一个默认配置。 :)

标签: angularjs gruntjs typescript


【解决方案1】:

TypeScript 领域已经发展了很多。 _all.ts 是一个非常古老的工作流程(在 tsconfig.json 成为事物之前)。编译器会解析它以找到所有构成the compilation context的文件

对于新代码 * 应该使用tsconfig.json * 使用模块(推荐--module commonjs) * 使用模块加载器(推荐 webpack)。

【讨论】:

  • 谢谢。我正在研究 tsconfig.json。
猜你喜欢
  • 2022-01-07
  • 2019-03-09
  • 2019-11-15
  • 2018-02-07
  • 2023-04-03
  • 2019-06-09
  • 1970-01-01
  • 2011-07-05
  • 2016-02-01
相关资源
最近更新 更多