close
Skip to content

Implicit type coersion of function to boolean in ternary operator #36921

@kenrick95

Description

@kenrick95

TypeScript Version: 3.7.x-dev.20200220

Search Terms: Implicit type coersion function ternary

Code

function isSomething(): boolean {
  return false
}
const haha = isSomething ? 'a' : 'b';

Expected behavior: Typescript should throw error in = isSomething ? instead of coercing isSomething to boolean

Actual behavior: Typescript coerced isSomething (function) to boolean

Playground Link: link

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions