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

Type-tests do not check for strict types #1174

Open
thoughtspile opened this issue Mar 3, 2023 · 0 comments
Open

Type-tests do not check for strict types #1174

thoughtspile opened this issue Mar 3, 2023 · 0 comments

Comments

@thoughtspile
Copy link

Hi! I borrowed your typing test suite for my library, banditypes — thanks for the excellent job!

I quickly discovered that test<Expected>() util checks that struct returns type assignable to Expected, not strictly equal to it. This might be dangerous, as a struct might check for a narrower type than expected:

test<string | number>((x) => {
  assert(x, string())
  return x
})

I suggest migrating the suite to expect-type or otherwise checking for strict equality. For reference, here's my MR with the change — it's not too hard.

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

1 participant