Skip to content

feat: improve expectTypeOf error messages#4206

Merged
sheremet-va merged 18 commits into
vitest-dev:mainfrom
mmkal:expect-type-0.17.0-1
Nov 10, 2023
Merged

feat: improve expectTypeOf error messages#4206
sheremet-va merged 18 commits into
vitest-dev:mainfrom
mmkal:expect-type-0.17.0-1

Conversation

@mmkal
Copy link
Copy Markdown
Contributor

@mmkal mmkal commented Oct 1, 2023

Description

Update expect-type version to the prerelease from mmkal/expect-type#16 - it should make error messages much better. This is hard to see in a repo where the assertions are passing, but see the snapshot update in that PR. (Note: the title is "improve expectTypeOf error messages" rather than referencing the update, since that's the net effect for end-users).

Here are what the examples of failing-test.d.ts in this repo look like:

Before:

image

After:

image

Related to #1954 - @sheremet-va FYI. I don't think it closes it as that issue seems. to be more about how it fits into the vitest API/usage generally.

I also linked to my library in the readme.

I've opened this as a draft as I'd like to publish v0.17.0 (rather than under the next dist-tag). I might actually bump to v1.0.0 too, I'm thinking of this as a release candidate (candidate).

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it. (There is one fix in Improve CLI error messages mmkal/expect-type#16 - expectTypeOf<any>().toBeBoolean() now produces an error, but I don't think that test needs to be duplicated here? I've checked this checkbox because I updated the error message snapshot tests.)
    - [ ] Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example. (err I needed to update it because I was updating a dependency? Should I delete this item?)

Tests

  • Run the tests with pnpm test:ci (also updated test/typescript/test/runner.test.ts and related snapshots to reflect the new error messages)
Note: test/coverage-test failed with the below error but I think it's unrelated? _Edit: Yep, I got the same error on main_ image

Also node.spec.ts and math.ts seemed to have a newline added to them for some reason. Not sure what that's about.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command. (_I haven't added docs, but I wrote lots in the pull request on expect-type. Is there a way to copy them here automatically and keep them in sync? Should I copy paste?)

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Loading
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

Successfully merging this pull request may close these issues.

2 participants