【问题标题】:Can I use CommonJS Module System in a typescript Project?我可以在打字稿项目中使用 CommonJS 模块系统吗?
【发布时间】:2018-09-01 04:34:36
【问题描述】:

我有一个新项目,我想使用 Visual StudioTypescriptASP.net CoreCommonJS 模块进行编码系统。实际上我需要一个模块系统来组织我的依赖项。我该怎么办?

我可以在使用 Visual Studio 的打字稿项目中使用 CommonJS 模块系统吗?

ts 配置:

{
  "compileOnSave": true,
  "compilerOptions": {
    "noImplicitAny": false,
    "noEmitOnError": true,
    "removeComments": false,
    "sourceMap": true,
    "target": "es5",
    "module": "commonjs"
  },
  "exclude": [
    "node_modules",
    "wwwroot"
  ]
}

【问题讨论】:

    标签: typescript asp.net-core commonjs


    【解决方案1】:

    是的,您可以像在 Javascript 中使用它一样使用它。 Typescript 是 Javascript 的超集,所有在 Javascript 中可能发生的事情,在 Typescript 中也都可能发生。

    参考这个:

    https://www.typescriptlang.org/docs/handbook/modules.html

    然后搜索 (ctrl/cmd + f) 以查找 'require'

    【讨论】:

      猜你喜欢
      • 2011-08-31
      • 2014-07-31
      • 1970-01-01
      • 1970-01-01
      • 2016-07-30
      • 1970-01-01
      • 2021-10-10
      • 2021-06-11
      • 1970-01-01
      相关资源
      最近更新 更多