ember-cli-typescript icon indicating copy to clipboard operation
ember-cli-typescript copied to clipboard

Enumerable.filterBy has a wrong return type

Open boris-petrov opened this issue 5 years ago • 1 comments

Which package(s) does this problem pertain to?

  • [x] @types/ember__array

Enumerable.filterBy (and possibly all other methods that are marked to return NativeArray<T>) doesn't actually return a NativeArray but rather a native JavaScript array. It's as simple as typing:

import { A } from '@ember/array';

const result = A().filterBy('foobar').mapBy('foobar');

This type-checks fine but at runtime blows up because filterBy doesn't return something that has a mapBy method.

boris-petrov avatar Mar 08 '20 12:03 boris-petrov

Thank you! I'll see if I can land a fix this week!

chriskrycho avatar Mar 08 '20 17:03 chriskrycho

Resolved by publishing types from Ember itself. (It's also possible this got fixed incidentally on DT at some point!)

chriskrycho avatar Sep 28 '23 23:09 chriskrycho