Premium support for our pure JavaScript UI components


Post by jarmen »

I was able to make this work by using @ts-ignore, the constructor should be exposed in such a way we can use it for this purpose.

export class AppResourceModel
  extends ResourceModel
{
  static get $$name(): string {
    return 'AppResourceModel';
  }

  static override get fields(): Partial<DataFieldConfig>[] {
    return [
      { name: 'newfield', type: 'string' },
  }

  constructor(
    config: Partial<AppResourceModelConfig>,
    a = null,
    b = null,
    c = null,
    d = null
  ) {
    // @ts-ignore
    super(config, a, b, c, d);
  }
  

Post by alex.l »

Thanks for informing us, I've opened a ticket to fix typings for that https://github.com/bryntum/support/issues/6077
For now, please use the code you posted as a workaround.

All the best,
Alex


Post by alex.l »

There is another valid workaround for this case:

resourceStore: {
  modelClass: Gate,
  createRecord(data, skipExpose = false, rawData = false) {
        let modelClass = this.modelClass as typeof Model;
        if (data.type === 'terminal') {
            modelClass = Terminal as typeof Model;
        }

    return new modelClass(data, this);
  }
},

All the best,
Alex


Post Reply