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

app's TS files do not properly overwrite an addon's JS files #774

Open
BoussonKarel opened this issue Aug 24, 2023 · 2 comments
Open

app's TS files do not properly overwrite an addon's JS files #774

BoussonKarel opened this issue Aug 24, 2023 · 2 comments

Comments

@BoussonKarel
Copy link

I have the following example component in my addon:

my-addon/addon/components/example/index.ts

import templateOnly from '@ember/component/template-only';
export default templateOnly();
```hbs
**my-addon/addon/components/example/index.hbs**
Whatever
``` **my-addon/app/components/example/index.js** ```js export { default } from 'my-addon/components/loading'; ```

Then in my app I completely replace it with a new template AND "backing class" with some Glint because why not:
my-app/app/components/index.ts

import templateOnlyComponent from '@ember/component/template-only';

interface LoadingSignature {
  Element: HTMLElement; // <i>
}

const LoadingComponent = templateOnlyComponent<LoadingSignature>();
export default LoadingComponent;

declare module '@glint/environment-ember-loose/registry' {
  export default interface Registry {
    Loading: typeof LoadingComponent;
  }
}

my-app/app/components/index.hbs

<div>Whatever</div>

This does not work and throws the following error:
image

It does work when using a JS file to overwrite the component:
my-app/app/components/index.js

// I have lost all my Glint stuff, because it's a JS file :'(
import templateOnlyComponent from '@ember/component/template-only';
const LoadingComponent = templateOnlyComponent();
export default LoadingComponent;

my-app/app/components/index.hbs

<div>Whatever</div>
@kategengler
Copy link
Member

I think this is a version of this issue typed-ember/ember-cli-typescript#780

Maybe @NullVoxPopuli would have more workarounds?

@NullVoxPopuli
Copy link

best advice I can give is to not override things this way (app-tree merging was a mistake! 🙈 ).

better to use a separately named thing, separate from the addon entirely, or patch the package.

just the same, v1 addons should be migrated to v2 -- which means that the problem shouldn't exist. (but please let me know if you run in to any goofiness)

re: ember-cli-typescript, it likely won't be updated, and folks should migrate away 😅
(the library can't be used in v2 addons, and isn't needed at all in apps)

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