Skip to content

Improve the typescript definitions #356

@43081j

Description

@43081j

Currently many of the exported types are any or very weakly typed.

It would be great if these types could be properly populated via the jsdoc.

For example, the various places you can pass options tend to accept any even though we have a strong type for the user options already.


I did actually start doing this but the overloads you have lead to a lot of craziness in the types.

For example, if we strongly type the overloads of resolve, the tests fail to compile because there are some which explicitly pass in undefined to ensure an error is thrown rather than bailing.

These tests make perfect sense but mean we end up having to dumb down the types to signatures nobody should ever really use. Alternatively we can double-cast undefined via jsdoc (to unknown then to string).

Similarly, the various overloads lead to all sorts of funky types, but are ultimately doable at least.

Maybe if i at least put a draft pr up, you can see what i mean.

cc @sokra maybe if you can list the "officially supported" overloads, that'd help us write the correct types

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