Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] class-based helpers throw weird error in strict mode (getDebugName) #19877

Closed
NullVoxPopuli opened this issue Dec 18, 2021 · 2 comments · Fixed by #19878
Closed

[Bug] class-based helpers throw weird error in strict mode (getDebugName) #19877

NullVoxPopuli opened this issue Dec 18, 2021 · 2 comments · Fixed by #19878

Comments

@NullVoxPopuli
Copy link
Sponsor Contributor

🐞 Describe the Bug

Error wasn't expected, but I think phrasing of the error could be improved?

image

🔬 Minimal Reproduction

  1. define class based helper in my-app/helpers
  2. using ember-template-imports (or strict mode some other way), define this template:
import MyHelper from 'my-app/helpers/my-helper';

<template>
  {{#let (MyHelper 1 2) as |result|}}
    {{result}}
  {{/let}}
</template>

😕 Actual Behavior

image

actual helper is:

import { getOwner } from '@ember/application';
import Helper from '@ember/component/helper';

export default class GetService extends Helper {
  compute([name]: [string]) {
    return getOwner(this).lookup(`service:${name}`);
  }
}

🤔 Expected Behavior

primarily, I expected this to work:

import service from 'limber/helpers/service';

<template>
  {{#let (service 'editor') as |context|}}

but a more helpful error would have been preferable, given the situation?

🌍 Environment

  • Ember: - 4.0.1
  • Node.js/npm: - 16.13.0 / 8.1.3 / yarn 1.22.17
  • OS: - Ubuntu 21.10
  • Browser: - FireFox

➕ Additional Context

Add any other context about the problem here.

@NullVoxPopuli
Copy link
Sponsor Contributor Author

Here is the code:

return getDebugName!(definition.class!['prototype']);

that matches what i'm seeing in my browser.
I though I'd add .class property to my helper to make this getDebugName correct, but then the owner is not passed to the helper (goes down a different instantiation path:

definition.class === undefined ? definition.create(this.ownerInjection) : definition.create();
)

NullVoxPopuli added a commit to NullVoxPopuli/ember-template-imports that referenced this issue Dec 18, 2021
@NullVoxPopuli
Copy link
Sponsor Contributor Author

NullVoxPopuli added a commit to NullVoxPopuli/ember.js that referenced this issue Dec 18, 2021
NullVoxPopuli added a commit to NullVoxPopuli/ember.js that referenced this issue Dec 18, 2021
NullVoxPopuli added a commit to NullVoxPopuli/ember.js that referenced this issue Dec 18, 2021
NullVoxPopuli added a commit to NullVoxPopuli/ember.js that referenced this issue Dec 28, 2021
NullVoxPopuli added a commit to NullVoxPopuli/ember.js that referenced this issue Dec 28, 2021
NullVoxPopuli added a commit to NullVoxPopuli/ember.js that referenced this issue Dec 29, 2021
NullVoxPopuli added a commit to NullVoxPopuli/ember.js that referenced this issue Dec 29, 2021
NullVoxPopuli added a commit to NullVoxPopuli/ember.js that referenced this issue Jan 7, 2022
kategengler pushed a commit that referenced this issue Jan 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant