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

.get() returns object array instead of type array #29

Open
gogogoober opened this issue Nov 3, 2021 · 2 comments
Open

.get() returns object array instead of type array #29

gogogoober opened this issue Nov 3, 2021 · 2 comments

Comments

@gogogoober
Copy link

Minimal reproduction of the bug with instructions:

This bug was replicated locally and on stackblitz

StackBlitz Link

  1. Open stackblitz from demo app.
  2. When "addTodo(name: string)
  3. Check type returned form this.model.get();

type = Object[]

Expected behavior:

Type should be Todo[]

Other information:

I would be willing to submit a PR to fix this issue:

[ ] Yes (Assistance is provided if you need help submitting a pull request)
[ x] No

@JoshuaMichaelHanson
Copy link

JoshuaMichaelHanson commented Mar 30, 2022

I am facing the same issue. For a workaround I am doing as unknown as Observable <T> In my code that uses the get() function. Would adding this same code to the model class fix the issue? If it will I can do a PR. If not please let me know what would fix the issue and I can work on it. I imported the file directly into my project so if I get it working there will push it back up for a PR. Cheers!

@JoshuaMichaelHanson
Copy link

Hi All,

In my testing the model does not like to work directly with TypeScript / ES classes but does function as expected when using Interface. Only real JS primitives work using Type Of, as Arrays technically are Objects. To test if and object is in-fact an array ES5 introduced the Array.isArray() function. I tested this and Array.isArray returns true with the data returned from get() so this can be closed! Cheers!
https://stackoverflow.com/questions/12996871/why-does-typeof-array-with-objects-return-object-and-not-array

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

2 participants