microsoft / microsoft/DefinitelyTyped-tools

$ExpectType doesn't expand types?

Open
#1,324 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
423
Forks
237
Avg merge
18h 18m
Merged PRs (30d)
11

Description

I'm contributing to a DT package, sometimes I got message implying it doesn't compare types structurally:

1. eslint: TypeScript expected type to be:
     boolean | "yes or no"
   got:
     "yes or no" | NonNullable<boolean | undefined> [@definitelytyped/expect]

It's inconvenient for writing tests as the result type might be wrapped inside another generic in the future.
If the wrapper type is not a simple utility type, it can be confusing what exact type this test is expecting.

I know I can add & {} to the return type in the definition, but that would also make it confusing for maintainers.
And I did have a grep on the DT codebase, it turns out I would be the first one to do & {} for the return type 😅

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the @definitelytyped/expect implementation and its existing $ExpectType comparison tests. Trace how the expected and actual types are obtained and compared, then extend the relevant behavior and add coverage showing the reported wrapped type is handled as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa, tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
66/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.