Skip to content

Improve error message "No valid runtime type for x given." #508

@marcj

Description

@marcj

https://github.com/deepkit/deepkit-framework/blob/92315f91ed4295d77b8c7bb693e8cbf8d5d32b23/packages/type/src/reflection/processor.ts#L363

@SamJakob had a great idea about improving this error message. Quote from discord:

Totally - I love the way Flutter does it’s error messages, they basically explain the issue in a fair bit of detail and then provide tips on how to fix it.

So for example you could have a helper function that detects if reflection is set in tsconfig.json and explains to the user that it’s not set and what it needs to be set for (in a fairly general way in case it’s a peer dependency in another framework like yours or mine) and that the user has to set it.

And then similarly for detecting if the typescript copy is patched

it's not always possible to detect tsconfig.json options or paths (since they might be provided by a build tool, or when run in the browser), but we could describe in a general way what needs to be enabled. And if the code runs in the server maybe try to check if there is a tsconfig.json and just read that file (works for beginners well enough that have likely a single tsconfig.json)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions