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

expectTypeOf - Deep nesting passes tests for different types #31

Closed
ivodolenc opened this issue May 23, 2023 · 2 comments
Closed

expectTypeOf - Deep nesting passes tests for different types #31

ivodolenc opened this issue May 23, 2023 · 2 comments

Comments

@ivodolenc
Copy link

Hi, I was just searching for some type testing lib and came across this nice project.

I did some quick nesting tests, so please correct me if I'm wrong.

I'm not sure if this is intentional, but here's an example to give you a better idea of what I mean:

Passes

import { expectTypeOf } from 'expect-type'

type Test = {
  object: {
    object: {
      number: number
      string: string
      boolean: boolean
      object: {
        number: number
        string: string
        boolean: boolean
      }
    }
  }
}

type TestNotEqual = {
  object: {
    object: {
      number?: number
      object?: {
        number?: number
      }
    }
  }
}

expectTypeOf<Test>().toEqualTypeOf<TestNotEqual>() // this passes the test and does not report an error

Not Passes

import { expectTypeOf } from 'expect-type'

type Test = {
  object: {
    string: string
    object: {
      object: {
        number: number
      }
    }
  }
}

type TestNotEqual = {
  object: {
    number: number // registers the number as an error since it should be a string, which is expected
    object: {
      object: {
        number: number
      }
    }
  }
}

expectTypeOf<Test>().toEqualTypeOf<TestNotEqual>() // this fails the test and throws an error
@mmkal
Copy link
Owner

mmkal commented May 29, 2023

Doesn't repro, likely fixed by #21 - @ivodolenc try v0.16.0

@mmkal mmkal closed this as completed May 29, 2023
@ivodolenc
Copy link
Author

Hey @mmkal, I just did a quick test, it works as expected in v0.16.0 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants