Enum inside class (TypeScript definition file)

后端 未结 7 1667
再見小時候
再見小時候 2021-01-31 01:20

I\'ve searched around but can\'t seem to find an answer for this, hopefully you can help. How can I add an enum to Image? This is what I would like ideally but I get an error.

相关标签:
7条回答
  • 2021-01-31 01:49

    I think I may have found a solution...whether it's valid TypeScript I don't know but it works and doesn't cause any compile errors. It's a combination of the above answers.

    declare module 'Lib' {
    
      module Graphics {
    
        module Image {
          enum State { }
          var STATE_IDLE: State;
          var STATE_LOADING: State;
          var STATE_READY: State;
          var STATE_ERROR: State;
        }
    
        class Image {
          constructor();
        }
    
      }
    
    }
    

    Can anyone spot any potential issues with this that I haven't noticed?

    0 讨论(0)
提交回复
热议问题