emberjs / emberjs/ember-render-modifiers
Improve the error message when `this` is undefined
- Dominant language
- TypeScript
- Stars
- 86
- Forks
- 34
- PR merge metrics
- No merged PRs in 30d
Description
If you try to use `this` within methods called by `{{on}}` and `{{fn}}`, they show a helpful error instructing the developer to use the `@action` decorator. The render modifiers could show something like that too.
Here's an example "error" use case for `did-insert`:
```
```
```
import Component from '@glimmer/component';
export default class CodeEditor extends Component {
renderEditor(el) {
console.log(this.args.code)
}
}
```
> TypeError: this is undefined
`{{fn}}` uses this error message:
> You accessed `this.arg2` from a function passed to the `fn` helper, but the function itself was not bound to a valid `this` context. Consider updating to usage of `@action`.
Contributor guide
Assessment
This issue has not been assessed yet.