Skip to content

undefined return type requires explicit return #40133

Closed
@saschanaz

Description

@saschanaz

TypeScript Version: playground

Search Terms: undefined return type

Code

function test(): undefined {
  console.log("hey")
}

Expected behavior: This should be allowed.

Actual behavior: TS requires the return type to be void or any.

Playground Link: https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABFApgZygCgJQC5HgAmKwMYKhiA3gFCKIQJpwA2KAdC3AOaYBEACxQBPPthoBfIA

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions