Typescript setup in VisualStudio 2015 giving error: `exports is not defined`. How to correctly setup?

Typescript setup in VisualStudio 2015 giving error: `exports is not defined`. How to correctly setup?

我刚开始使用打字稿,我正在用打字稿进行导出导入

但是当我开始时我在导出时遇到错误,

Object.defineProperty(exports, "__esModule", { value: true });

错误是

Uncaught ReferenceError: exports is not defined

经过一些 google 我经历了

但根据那个答案,我的项目应该包含 tsconfig.json, common.js

但我没有这些

这是我项目的截图

我该怎么办?

module.exports,或者更短的版本exports是一个只存在于Node.js

中的对象

尝试在浏览器中使用该变量会给您 Uncaught reference error: exports is not defined

Node.js documentation reference for the exports shortcut

您应该在您的项目中添加一个tsconfig.json,例如您将module设置为es6

您的设置可能默认为 "commonjs",它要求您有一个 exports 对象,而您在浏览器中没有。查看 here 以获取更多阅读材料。