I have to try to create some test usen js Composition, I'm following this article: https://www.koderhq.com/tutorial/javascript/composition/#what-is
I have a js class
class FileField {
constructor () {
}
/**
* Upload file to file field.
*
* @param {string} InputAttribute
* @param {string} url
* @param {string} AltAttribute
*/
uploadField(InputAttribute, url, AltAttribute ) {}
}
export default {FileField}
And I try to use this class in this way in another class:
import { DefaultContent } from "./DefaultContent/DefaultContent";
import { PROPERTY } from "./DefaultContent/DefaultContent";
import { FileField } from "./DefaultContent/FileField";
export default class ArticlePage extends DefaultContent {
constructor(FileField) {
this.fileField = new FileField();
}
fillImageField() {
// Upload the file
this.fileField.uploadFile(
this.imageInput,
"/node/add/article?element_parents=field_image/widget/0&ajax_form=1&_wrapper_format=drupal_ajax",
this.imageAltDescription,
);
}
}
I get the error: > FileField is not a constructor
I have checked articles and StackOverflow questions but none works with my code.
Thanks.