如何在Typescript中导入枚举

时间:2016-09-20 20:00:03

标签: typescript import enums

我有以下两个文件:bag.js

import {BagType} from "./bagType"     //this line of code gives an error message: bagtype.ts is not a modul
import {Present} from "./present";

export class Bag {

    private maxWeight: number;
    private bagType: BagType;
    private presents: Array<Present> = new Array<Present>();

    constructor(maxWeight: number, bagType: BagType) {
        this.maxWeight = maxWeight;
        this.bagType = bagType;
    }

    public addPresent(present: Present){
        this.presents.push(present);
    }
}

和bagType.js

enum BagType {

    Canvas,
    Paper
}

我的问题是下一个:如何将枚举BagType导入Bag类?

1 个答案:

答案 0 :(得分:3)

我尝试了它并且它适用于:

import {BagType} from "./bagType";

if CheckBoxesB.IsSelected('All') ==  True:
  CheckBoxesA.Reset()