Skip to content

Function that always throws is not inferred as having never return type #16608

Closed
@masaeedu

Description

@masaeedu

TypeScript Version: 2.5.0-dev.20170618

Code

function fail1() {
  throw new Error()
}

const fail2 = function () {
  throw new Error()
}

Expected behavior:
Inferred return type of both functions is never

Actual behavior:
Only the return type of the second function is never. The return type of fail1 is inferred as void.

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions