Skip to content

fix(type-factories): Correct types on instanceOf type factory#79

Merged
JoseLion merged 1 commit into
mainfrom
fix/instanceof-type-factory
Nov 22, 2022
Merged

fix(type-factories): Correct types on instanceOf type factory#79
JoseLion merged 1 commit into
mainfrom
fix/instanceof-type-factory

Conversation

@JoseLion

@JoseLion JoseLion commented Nov 8, 2022

Copy link
Copy Markdown
Contributor

This PR corrects the types of the TypeFactories.instanceOf(..) helper. The issue was that the assertion factory was creating an assertion for the constructor instead of the instance. Using the alias Constructor<T> instead resolves the issue as the assertion factory will create an instance for T instead.

Example:

class Car {

  private model: string;

  constructor(model: string) {
    this.mode = model;
  }
}

expect(value)
  .asType(TypeFactories.instanceOf(Car))
  .toBeEqual(new Car("Porsche 911"));

@byrpatrick byrpatrick left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 💯

@JoseLion
JoseLion merged commit c00bd31 into main Nov 22, 2022
@JoseLion
JoseLion deleted the fix/instanceof-type-factory branch November 22, 2022 23:22
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants