Skip to content

TS Target Updated to ES6 & Update Dependencies

Latest
Compare
Choose a tag to compare
@ericdowell ericdowell released this 02 Jul 23:36
· 1 commit to master since this release

Details on target Change

When attempting the following:

import {
  ApiMixin,
  AxiosErrorMixin,
  UserEndpoint,
  HandleErrorMixin,
  SessionCsrfCookieMixin,
  FormMixin,
} from 'resource-endpoint'

class UserBase extends SessionCsrfCookieMixin(
  ApiMixin(FormMixin(UserEndpoint)),
) {}


class UserQuery extends AxiosErrorMixin(UserBase) {}

export class User extends HandleErrorMixin(UserBase) {
  /**
   *
   * @returns {UserQuery}
   */
  get reactQuery() {
    return new UserQuery()
  }
}

An error of Uncaught TypeError: Class constructor UserBase cannot be invoked without 'new' would occur in the browser.

Issue seems to be around classes transpiled to ES5. Mainly, that native ES6 classes cannot extend the the transpiled classes.

The problem is that the class extends native ES6 class and is transpiled to ES5 with Babel. Transpiled classes cannot extend native classes, at least without additional measures.

Source: https://stackoverflow.com/a/51860850