[Typescript] Abstract Classes

You cannot create a instance of abstract class. An abstract class mean to be extended.

abstract class Size {
    constructor(public sizes: string[]) {}
    
    set availableSizes(sizes: string[]) {
        this.sizes = sizes;
    }
    
    get avaialableSizes() {
       return this.sizes
    }
}

new Sizes(['small']) // Error: Cannot create an instance of the abstract class 'Sizes'

 

posted @ 2022-10-13 22:20  Zhentiw  阅读(19)  评论(0编辑  收藏  举报