-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Issue with declare class fields #242
Comments
what is supposed to be setting I made a little demo here of the underlying transform: https://stackblitz.com/edit/stackblitz-starters-nmegkz?description=Starter%20project%20for%20Node.js,%20a%20JavaScript%20runtime%20built%20on%20Chrome%27s%20V8%20JavaScript%20engine&file=index.mjs&title=node.new%20Starter and the output is: // ❯ node ./index.mjs
import SomeAddonComponent from 'some-addon/components/some-component';
import layout from 'some-addon/templates/components/some-component';
let MyComponent = class MyComponent extends SomeAddonComponent {
interactive: boolean;
// ^ of note, `declare` has been dropped
someFunction() {
if (this.interactive) {}
super.someFunction(event);
}
};
export default setComponentTemplate(layout, MyComponent); but, in both cases, I would expect something to set |
in any case, I opened embroider-build/content-tag#77 |
In fact, export DEFAULT from './some-addon-default-config'
class SomeAddonComponent {
get interactive() {
return DEFAULT.interactive; // Default value - true
}
...
}
class MyComponent extends SomeAddonComponent {
declare interactive: boolean;
someFunction() {
if (this.interactive)
...
super.someFunction(event);
}
} That is, |
since it's defined in your parent class, TS shouldn't require the However, I do think this is probably a bug here: embroider-build/content-tag#77 (idk if you want to poke at a PR for that 😓 ) |
Perhaps the problem is that I'm importing js and not ts. What I'm actually trying to do is extend this component,
Аs I see, the source code is in Rust, but unfortunately I’m not familiar with it |
You could write a dts file give that component a type?
No worries! |
In general I can, but in this case I am more concerned about If someone manages to solve this problem, I will be glad that other developers will not have to deal with this I would rather take a PR for this addon to make it typed out of the box, and I am concerned that it uses the old file structure, which, according to my observations, causes problems with its import in |
it's also deprecated for removal in ember-source v6.0
I'm not 100% on when exactly component co-location was introduced (like if it was earlier or if 3.13 is the minimum), but if you only support ember-cli/ember-source versions that also support component co-location -- there would be no issue in the internal migration of the addon. (though, the migration would be |
I managed to find RFCS, and it looks like this is good news for that addon. Thanks for the tip :3 |
I'm not entirely sure that the problem is related to this addon specifically, but it is clearly related to the
*.gts.
filesI have a situation where I need to extend a component from an addon. The addon class has a field
interactive
and I need to check this field to be true before making any further decisions in the code.I had this working piece of code in a
*.ts
file and decided to move it to*.gts
.declare interactive
is used because the linter complains about the absence of thethis.interactive
field, in order to actually declare the existence of the field forciblyAfter changing the extension to
*.gts
the code stopped working correctly. As a result of debugging, I noticed thatthis.interactive
containsundefined
instead of a boolean value. Looking at the prototype of the object, I noticed that the class actually overrides theinteractive
field, although the*.ts
files do not do this.I perceived
declare
as part of typescript, so I can’t fully understand, am I using things for other purposes, or is there some kind of conflict with the*.gts
files?The text was updated successfully, but these errors were encountered: