emberjs / emberjs/ember.js

[Feature] Better template error reporting

Open
#20,267 1 comment 3 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
22.6k
Forks
4.2k
Avg merge
3d 12h
Merged PRs (30d)
15

Description

Ember has a history of not-so-friendly errors. Let's fix that!

For example:

This error:
```
Uncaught Error:
Expected a dynamic component definition,
but received an object or function that did not have a component manager associated with it.
The dynamic invocation was `<(result of a `unknown` helper)>` or `{{(result of a `unknown` helper)}}`,
and the incorrect definition is the value at the path `(result of a `unknown` helper)`,
which was: Object
```

It's not at all clear what is going on, or what part of the template this is happening from.
Borrowing from Rust, and other more modern compilation tools, we should instead provide an error in this form:
```hbs
10 | {{#each @options as |option|}}
^ value defined here -- is of type: `Object`
11 |
^ used here -- expected `option` to be able to be used as a component because `option` was used in the `` syntax.
if `option` is meant to be used as a component, ensure a corresponding Component Manager is registered for type `Object`.
if `option` is not meant to be used as a component, consider renaming the variable
```

I know this will require a _ton_ of VM work, but it's vital, and important for our ecosystem's DX.
I don't know enough about the VM to get started on this though, but I imagine this would require a ton of template-parsing during runtime when things went wrong -- how do we map runtime to templates?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.