使用TypeScript和es5时为什么会出现“ ReferenceError:未定义导出”的问题?

时间:2020-03-28 23:47:23

标签: angularjs typescript

我正在尝试将AngularJS应用程序转换为使用TypeScript。但是,我编译的JS给我以下错误:

ReferenceError:未定义导出

tsconfig.json:

{
"compilerOptions": {
    "outDir": "./built",
    "allowJs": true,
    "target": "es5"
},
"include": [
    "components/**/*",
    "factories/**/*"
]
}

header.component.ts:

import angular from "angular";

angular.module("playerEvaluator", ["ui.router", "ngMaterial"])
.component('headerComponent',
{ 
    templateUrl: "templates/header.tmpl.html",
    controllerAs: "$ctrl",
    bindings: {},
    controller: function ($scope, $state, $rootScope) {    
        //Pages
        this.pages = [
            {
                name: "Teams",
                state: "teams"
            }
        ];        
        //Go to selected page
        this.goToPage = (state: string) => {
            $state.go(state)
        }
    }
});

正是这一行在 header.component.js中抛出错误:

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

如何解决此错误?

0 个答案:

没有答案