Skip to content

Implementing abstract class does not force you to implement all methods but it should? #32478

@ORESoftware

Description

@ORESoftware

Potentially a bug, or just unexpected behavior. So I have this abstract class:

export abstract class Transformer {
  
  abstract identifyViaRawStr: () => boolean;
  abstract identifyViaJSObject: (v: any) => boolean;
  abstract getValue: (v:any) => string;
  abstract transformToBunionFormat: (v: any) => BunionJSON

}

and then I implement it with another class:

const c = new (class implements Transformer{
  
  getValue(v: any) {
    return '';
  }
  
  identifyViaJSObject: (v: any) => boolean;
  identifyViaRawStr: () => boolean;
  transformToBunionFormat: (v: any) => BunionJSON;
  
});

the above compiles fine, but looks funny since 3/4 methods are not implemented. It transpiles without an error to:

class Transformer {
}
exports.Transformer = Transformer;
const c = new (class {
    getValue(v) {
        return '';
    }
});

I mean maybe this is correct, but it's not expected at least for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions