Enum inside class (TypeScript definition file)

后端 未结 7 1891
再見小時候
再見小時候 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:38

    You could create a module and class with the same name. It might also help to rename your enum so that you don't have to say State twice:

    declare module 'Lib' {
        export module Graphics {
            export class Image {
                constructor();
            }
    
            export module Image {
                export enum State {
                    Idle,
                    Loading,
                    Ready,
                    Error
                }
            }
        }
    }
    

提交回复
热议问题