Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compilation errors for primitive type assertions #167

Closed
scizor666 opened this issue Nov 16, 2021 · 2 comments · Fixed by #168
Closed

compilation errors for primitive type assertions #167

scizor666 opened this issue Nov 16, 2021 · 2 comments · Fixed by #168
Labels
types TypeScript type definitions
Milestone

Comments

@scizor666
Copy link

scizor666 commented Nov 16, 2021

Support plan

  • is this issue currently blocking your project? (yes/no): no
  • is this issue affecting a production system? (yes/no): yes

Context

  • node version: v12.22.7
  • module version with issue: 8.0.4
  • last module version without issue: 8.03
  • environment (e.g. node, browser, native): node
  • used with (e.g. hapi application, another framework, standalone, ...):standalone
  • any other relevant information:

What are you trying to achieve or the steps to reproduce?

function foo(): number | undefined {
 //
}

const value = foo();
expect(value).to.be(123)

function bar(): boolean {
 //
}
expect(bar()).equals(false)

What was the result you got?

compilation errors like:

Argument of type '123' is not assignable to parameter of type 'never'
Argument of type 'false' is not assignable to parameter of type 'never' 

What result did you expect?

no compile error

@scizor666 scizor666 added the support Questions, discussions, and general support label Nov 16, 2021
@kanongil
Copy link
Contributor

Thanks for the report. This seems to be an issue with the recent #163. I'm looking into a fix.

@kanongil kanongil added types TypeScript type definitions and removed support Questions, discussions, and general support labels Nov 17, 2021
@kanongil
Copy link
Contributor

I made a fix in #168.

devinivy pushed a commit that referenced this issue Nov 20, 2021
* Don't narrow generic on type specific assertions. Closes #167

* Allow specifying custom type using just 1 parameter
@devinivy devinivy added this to the 8.0.5 milestone Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
types TypeScript type definitions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants