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

Error importing component classes (TypeScript) #1341

Closed
esbanarango opened this issue Jan 27, 2023 · 3 comments
Closed

Error importing component classes (TypeScript) #1341

esbanarango opened this issue Jan 27, 2023 · 3 comments

Comments

@esbanarango
Copy link

esbanarango commented Jan 27, 2023

🐞 Bug description

Importing a component class ends up being a different object than the class itself. Preventing extending it or interacting with it.

This works fine without using TypeScript

πŸ‘¨β€πŸ”¬ Example

Trying to stub some properties or methods of a Component class.

// This is no longer a valid/normal Class as Embroider has converted into a different (owner) object.
import TestComponent from 'owner-embroider-issue/components/test-component';

module('Integration | Component | test-component', function (hooks) {
  setupRenderingTest(hooks);

  test('...', async function (assert) {
    this.owner.register(
      'component:test-component',
      class extends TestComponent {
        // Propertier and methods I want to override
      }
    );

    await render(hbs`<TestComponent />`);
  });
});

When doing: import TestComponent from 'owner-embroider-issue/components/test-component';, TestComponent is no longer a Class, but a different "object", so we can not "extend" it anymore.

πŸ˜• Actual Behavior

215009088-21f31d51-9678-4d68-9d91-cbd6a75d890b_png__2532Γ—1606__πŸ”Š

βœ–_OwnerEmbroiderIssue_Tests_πŸ”Š

πŸ€” Expected Behavior

This is the output without using Typescript
Cursor_and_OwnerEmbroiderIssue_Tests_πŸ”Š

🌍 Environment

"@embroider/compat": "^2.0.2",
"@embroider/core": "^2.0.2",
"@embroider/webpack": "^2.0.2",
"ember-source": "~4.10.0",
"ember-cli": "~4.10.0",
"ember-cli-typescript": "^5.2.1",
"typescript": "^4.9.4",
"webpack": "^5.75.0"

πŸ”€ App to reproduce the issue

https://github.com/esbanarango/owner-embroider-issue/tree/typescript

@esbanarango esbanarango changed the title Error exporting component classes (Typescript) Error exporting component classes (TypeScript) Jan 27, 2023
@esbanarango esbanarango changed the title Error exporting component classes (TypeScript) Error importing component classes (TypeScript) Jan 27, 2023
@dmuneras
Copy link

Got the same issue :(

@ef4
Copy link
Contributor

ef4 commented Jan 27, 2023

I think this and #1336 are probably the same bug.

ef4 added a commit that referenced this issue Jan 27, 2023
I don't really know what 7882a2d was trying to achieve and it definitely looks weird and it's the cause of #1336 and probably #1341.

Maybe CI will tell me why this was done in the first place...
@ef4
Copy link
Contributor

ef4 commented Jan 27, 2023

Fixed in #1342 and I confirmed that it fixes your reproduction.

@ef4 ef4 closed this as completed Jan 27, 2023
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

No branches or pull requests

3 participants