我有一个新项目,我想使用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"
]
}
是的,您可以按照在Javascript中使用它的方式使用它。 Typescript是Javascript的超集,Javascript中所有可能的东西也可以在Typescript中使用。
参考:
https://www.typescriptlang.org/docs/handbook/modules.html
并搜索(ctrl / cmd + f)为'require'