Skip to content

Passing never type as a function parameter does not fail type checkΒ #56952

Closed as not planned

Description

πŸ”Ž Search Terms

never parameter argument

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about 'never'

⏯ Playground Link

https://www.typescriptlang.org/play?#code/FAMwrgdgxgLglgewgAhAhAKARgQwE7IBcyAzjHnBAOYCUyA3sMslEiQgDYCmAdBwlWz4aAbmABfYKEixEKKlxgA5LgDcueDHWIQ1Ghk2QwAFngQB3ZLssBRPGc0ADJQgAOXR6IlS0mBcr1NGlEgA

πŸ’» Code

function foo(bar : string) {
  console.log(bar);
}

function getNever() : never {
  throw new Error(`Nope`);
}

foo(getNever());

πŸ™ Actual behavior

No type errors

πŸ™‚ Expected behavior

Type error: can not pass type never to function foo

Additional information about the issue

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions