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
Property 'pushObject' does not exist on type '{}[]'.ts(2339)
This also happens for other properties of MutableArray, e.g. firstObject, yet all other other type imports from ember-source works well, as far as I can see.
🤔 Expected Behavior
Types of MutableArray to be imported correctly – as they are from the "old" @types/ember__array package. Test that the 'old way' runs well in the same environment by simply removing the type imports on line 8:
-import 'ember-source/types/preview';
^ no errors after removing this line
🌍 Environment
Ember: 4.12.0 and 5.1.0-beta1
The text was updated successfully, but these errors were encountered:
Note that this will fail at runtime unless Array's prototype-extensions are enabled (which you shouldn't do) - so the error is correct - there is no such method on a native JS array.
By default, Ember.js will extend the prototypes of native JavaScript arrays to implement the Ember.Enumerable, Ember.MutableEnumerable, Ember.MutableArray and Ember.Array interfaces. This polyfills ECMAScript 5 array methods in browsers that do not implement them, adds convenience methods and properties to built-in arrays, and makes array mutations observable.
There are no errors at runtime in the browser, only at compile time from typescript.
🐞 Describe the Bug
Importing types from
ember-source/types/preview
breaks types ofMutableArray
properties on tracked arrays.🔬 Minimal Reproduction
Clone this repo: https://github.com/johanrd/ember-typescript-reproducible-mutable-array
😕 Actual Behavior
Open app.ts, and see typescript error 2339 on line 18:
this.list.pushObject(object)
:This also happens for other properties of MutableArray, e.g.
firstObject
, yet all other other type imports from ember-source works well, as far as I can see.🤔 Expected Behavior
Types of
MutableArray
to be imported correctly – as they are from the "old"@types/ember__array
package. Test that the 'old way' runs well in the same environment by simply removing the type imports on line 8:-import 'ember-source/types/preview';
^ no errors after removing this line
🌍 Environment
4.12.0
and5.1.0-beta1
The text was updated successfully, but these errors were encountered: