Skip to content

Suggestion: error when immediate function expression which returns a value is assigned to function type with void return type #19014

Closed
@NaridaL

Description

@NaridaL

This would be the analog of the error for additional properties in object literals for function return values.

TypeScript Version: 2.5.3 / nightly (2.6.0-dev.20171007)

Code

declare function voidCallback(cb: () => void)

// actual: no error
// expected: error: callback ignores return value 
voidCallback(() => 23)

const f = () => 45

// should still work:
voidCallback(f)

voidCallback(() => {
    // should still be allowed for flow control
    return
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already created

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions