Skip to content

Intersection Types/function (something like assert): TS7030 TS2345 #30064

Closed
@zaoqi

Description

@zaoqi

TypeScript Version: 3.3.3333

Search Terms:

Code

    const assert: ((x: false) => nerver) & ((x: true) => void) = (x: boolean) => {
        if (x === false) {
            return error()
        }
    }

Expected behavior:

Actual behavior:

lang.ts:1257:66 - error TS7030: Not all code paths return a value.

1257     const assert: ((x: false) => nerver) & ((x: true) => void) = (x: boolean) => {

lang.ts:1345:20 - error TS2345: Argument of type 'boolean' is not assignable to parameter of type 'true'.

1345             assert(!eof())

Playground Link:

Related Issues:

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