TypeScript:作为类属性的对象(非静态或静态)

时间:2018-09-09 11:24:58

标签: typescript types

如何在foo下方注释BARExampleClass

class ExampleClass {
    private foo = {
        one: 1,
        two: 2
    };

    private static BAR = {
        one: 'one',
        two: 'three'
    }
}

重要的案例:

enter image description here

文本版本:

import { Vue, Component, Prop } from 'vue-property-decorator';

@Component
export default class Bootstrap4AlertsCodeGenerator extends Vue {

  static CONTEXT_CSS_CLASSES: object = {
    PRIMARY: 'primary',
    SECONDARY: 'secondary',
    SUCCESS: 'success',
  };

  contextCssClass: string = Bootstrap4AlertsCodeGenerator.CONTEXT_CSS_CLASSES.SECONDARY;

  public get isSelectContextCssClassRadiobuttonActive(): (contextCssClass: string) => boolean {
    return contextCssClass => this.contextCssClass === contextCssClass;
  }
}

错误:

TS2339: Property 'SECONDARY' does not exist on type 'object'.

0 个答案:

没有答案