Skip to content

$ExpectType doesn't expand types? #1324

Description

@sharpchen

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 😅

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions