You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upgrading to @apollo/client 3.4.0-beta.6 breaks with TypeError: class constructors must be invoked with 'new' using Next.js. Works fine with @apollo/client 3.4.0-beta.4. Most likely due to changes in PR #7615.
Actual outcome:
TypeError: class constructors must be invoked with 'new'
How to reproduce the issue:
Clone repo https://github.com/rriski/with-apollo. Run with yarn dev. Works with 3.4.0-beta.4, breaks with 3.4.0-beta.6 -> TypeError: class constructors must be invoked with 'new'.
Now that the zen-observable-ts package has the ability to export
Observable as a native class (#7615), we need to be careful when extending
Observable using classes (like ObservableQuery and Concast) that have been
compiled to ES5 constructor functions (rather than native classes),
because the generated _super.call(this, subscriber) code throws when
_super is a native class constructor (#7635).
Rather than attempting to change the way the TypeScript compiler
transforms super(subscriber) calls, this commit wraps Observable.call and
Observable.apply to work as expected, by using Reflect.construct to invoke
the superclass constructor correctly, when the Reflect API is available:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/construct
Another option would be to ship native class syntax with @apollo/client,
by changing the "target" in tsconfig.json from "es5" to "es2015" or later,
so that consumers of @apollo/client would be forced to compile native
class syntax however they see fit. That would be a more disruptive change,
in part because it would prevent subclassing Apollo Client-defined classes
using anything other than native class syntax and/or the Reflect.construct
API, which is the very same problem this commit is trying to fix for the
Observable class.
Intended outcome:
Upgrading to @apollo/client 3.4.0-beta.6 breaks with
TypeError: class constructors must be invoked with 'new'
using Next.js. Works fine with @apollo/client 3.4.0-beta.4. Most likely due to changes in PR #7615.Actual outcome:
TypeError: class constructors must be invoked with 'new'
How to reproduce the issue:
Clone repo https://github.com/rriski/with-apollo. Run with
yarn dev
. Works with 3.4.0-beta.4, breaks with 3.4.0-beta.6 ->TypeError: class constructors must be invoked with 'new'
.Versions
The text was updated successfully, but these errors were encountered: