Skip to content
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

Uncaught TypeError: Class constructor ComputedProperty cannot be invoked without 'new' #275

Closed
Krzyrok opened this issue Feb 1, 2019 · 1 comment

Comments

@Krzyrok
Copy link

Krzyrok commented Feb 1, 2019

Hi. I've encountered a problem when I've updated ember-source to the newest stable version (3.7.2).

error:

Uncaught TypeError: Class constructor ComputedProperty cannot be invoked without 'new'
    at new TaskProperty
    at task

I've seen the issues:

But: I've upgraded ember-concurrency to newer version: 0.8.24 (mentioned in the issue) and 0.8.27 (the newest one) - none of them helped.
I don't use native classes, ember-native-class-polyfill nor ember-decorators.
I use on other hand typescript (2.9.2) and ember-typescript (1.5.0).

Usage in the code:

export default class SomeService extends Service.extend({
  _someTask: task(function* (this: SomeService) {
    const properties = yield this.api.callToApi();
  }).maxConcurrency(1).restartable(),
}) {};

Error is thrown on task construction, first line: _someTask: task(function* (this: SomeService) {

Environment details:

OS: Debian GNU/Linux 9.6
node version: 10.13.0
npm version: 6.4.1
yarn version: 1.13.0

ember-concurrency version: 0.8.24 and 0.8.27 (the newest one)
ember-source version: 3.8.0-beta.3, 3.7.2 (current stable version), 3.7.0., 3.6.1 (3.6.0 I couldn't test)
typescript: 2.8.3
ember-cli-typescript: 1.3.0

code which failed (showed in console):

  function TaskProperty(taskFn) {
    let tp = this;
    _utils._ComputedProperty.call(this, function (_propertyName) {
      taskFn.displayName = `${_propertyName} (task)`;
      return Task.create({
        fn: tp.taskFn,
        context: this,
        _origin: this,
        _taskGroupPath: tp._taskGroupPath,
        _scheduler: (0, _propertyModifiersMixin.resolveScheduler)(tp, this, _taskGroup.TaskGroup),
        _propertyName,
        _debug: tp._debug,
        _hasEnabledEvents: tp._hasEnabledEvents
      });
    });

    this.taskFn = taskFn;
    this.eventNames = null;
    this.cancelEventNames = null;
    this._observes = null;
  }

exact line: _utils._ComputedProperty.call(this, function (_propertyName) {

@Krzyrok
Copy link
Author

Krzyrok commented Feb 1, 2019

Ah, I figured out that some another addon had a dependency on ember-concurrency. And it was installed some time ago - so it was resolved to older version (record in yarn.lock was pinned to specific, old version). Whole time ember was taking this old version (despite I had newer version in my package.json).

More details here: #207 (comment)

yarn list ember-concurrency (or npm ls ember-concurrency) helped to figure this out.

Final fix: removing the record in yarn.lock responsible for resolving package (ember-concurrency) as dependency. In my case there was: ember-data-copyable, ember-power-calendar, ember-power-select. All of those packages had specified the dependency with ^, so yarn install took newer version of ember-concurrency (for all of these addons): 0.8.27.

For other people: check if yarn list [package] (or npm ls [package]) shows that you have only the new package. If not - then modifying yarn/npm.lock can help. If not: upgrade of addon (new dependency specified). If this also didn't help: fork of addon and manual update of dependecy.

This addon looks that can be helpful to detect such situation: https://github.com/salsify/ember-cli-dependency-lint

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant