Skip to content

Crash on return [of] incorrect function type #6

@Bored66

Description

@Bored66

Code:

type myFnT1 = (closeAction: myFnT) => number;

function myFunc(closeAction: () => void): number {
    return 5;
}

function getDropDownFunction(
    controlId: string
): myFnT1 {
    switch (controlId) {
        case "paste":
            return myFunc;
        default:
            console.log("Undefined Control");
            return () => 7;                                      //<------Error
    }
}


let fn = getDropDownFunction("paste1");

fn(() => { console.log("close") })

Actual outcome:

Undefined Control

Program received signal SIGSEGV, Segmentation fault.
0x0000555555562b1b in __ts_main () at lib.std.stubs.d.ts:112

Expected outcome:

Undefined Control

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions