Typescript strongly type void Function

Discussão em 'Angular' iniciado por johnny 5, Fevereiro 8, 2025.

  1. johnny 5

    johnny 5 Guest

    I'm trying to write an interface which takes a function in as a parameter:

    Currently I'm trying this

    export interface EditOptions {
    isEditing: boolean;
    save: () => {};
    }


    I've tried a few things to assign the function:

    editOptions: EditOptions = { isEditing: false, save: this.save };
    editOptions: EditOptions = { isEditing: false, save: () => { this.save() } };


    Neither work instead I receive this error:

    [​IMG]

    I Know that for now I can use :any but what is the proper way to strongly type a void function

    Continue reading...

Compartilhe esta Página