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

问题描述 投票:0回答:1

我有一个新项目,我想使用Visual Studio,Typescript,ASP.net Core和CommonJS Module System进行编码。实际上我需要一个模块系统来组织我的依赖项。我该怎么办?

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

ts config:

{
  "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个回答
0
投票

是的,您可以按照在Javascript中使用它的方式使用它。 Typescript是Javascript的超集,Javascript中所有可能的东西也可以在Typescript中使用。

参考:

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

并搜索(ctrl / cmd + f)为'require'

© www.soinside.com 2019 - 2024. All rights reserved.