emberjs / ember.js

Ember.js - A JavaScript framework for creating ambitious web applications
https://emberjs.com
MIT License
22.47k stars 4.21k forks source link

[Bug] Cannot use `tracked` in a class that might later have a Mixin applied with the same prop #20187

Open runspired opened 1 year ago

runspired commented 1 year ago

Discovered this in 3.28 but it seems to still be present on master.

The basic setup

import { tracked } from '@glimmer/tracking';
import EmberObject from '@ember/object';

export default class Foo extends EmberObject {
  @tracked foo;
}

// ... then in a consuming app or another file
import Foo from './foo';
import Mixin from '@ember/object/mixin';

const MixinWithFoo = Mixin.create({
  foo: null
});

export default Foo.extend(MixinWithFoo);

The error

vendor.js:15986 Uncaught TypeError: desc.teardown is not a function
    at mergeProps (vendor.js:15986:16)
    at mergeMixins (vendor.js:15937:11)
    at mergeMixins (vendor.js:15939:11)
    at mergeMixins (vendor.js:15939:11)
    at mergeMixins (vendor.js:15939:11)
    at applyMixin (vendor.js:16084:5)
    at Mixin.apply (vendor.js:16330:14)
    at Class.proto (vendor.js:30068:31)
    at Class.eachComputedProperty (vendor.js:30025:12)
    at get relationshipsObject (vendor.js:227580:12)

Which happens due to this:

image
chriskrycho commented 1 year ago

This is, I think, the same as #18860—the problem is that our native class support does not support "zebra-striping" this way, i.e. switching between classic, native, and classic again classes for authoring. I have an idea of how to possibly fix this, and opened #20129 as a home for it and to have a failing test for it, but it hasn’t made it to the top of my priority list yet.