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

Component Store losing typing after adding the second property to the vm$. #2944

Closed
beeman opened this issue Feb 22, 2021 · 5 comments
Closed

Comments

@beeman
Copy link

beeman commented Feb 22, 2021

Minimal reproduction of the bug/regression with instructions:

In order to show this bug I need 2 apps, one with version 10 and one with version 11.

Additionally, to make the explanation a bit easier I created a 2-minute video that shows the issue.

In essence:

  • Add @ngrx/component-store v11 to an app
  • Add a simple store exposing 1 property in the vm, make sure it auto-completes in the template
  • Adding a second property breaks the auto-completion in the template

Doing the same with Component Store v10 works as expected.

I can imagine it has something to do with #2841 as that changed what gets returned by the selects.

Expected behavior:

The typing should behave the same after adding more properties.

Versions of NgRx, Angular, Node, affected browser(s) and operating system(s):

Latest Angular versions.

@ngrx/component-store v10: works as expected.
@ngrx/component-store v11: does not work as expected.

Other information:

I thought I went crazy, but luckily @nartc confirmed that he sees the same behavior.

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

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

@alex-okrushko
Copy link
Member

Thanks @beeman. I think this is the first bug report with a great explanation in a video format 🙂 👍

I didn't investigate yet, but it's quite puzzling that it's fully typed at readonly vm$ and then it's Observable<unknown> in the template.
Screen Shot 2021-02-21 at 10 16 21 PM

Screen Shot 2021-02-21 at 10 19 19 PM

Doesn't make much sense to me. It almost feels like the Angular Language Service issue.

@beeman
Copy link
Author

beeman commented Feb 22, 2021

Thanks for your fast response @alex-okrushko!

I just ran the same experiment with an Angular v10 app (10.2.4) to test that behavior, but it seems to behave the same there.

For reference, Ng10 + Component Store v10 and Ng10 + Component Store v11.

@beeman
Copy link
Author

beeman commented Feb 22, 2021

Another thing that's probably good to note, if I manually type the vm$, it does work as expected in the template. For now this is my workaround.

  readonly vm$: Observable<{ loading?: boolean, items?: Item[] }> = this.select(
    // Component Store v11
    this.items$,
    this.loading$,
    (items, loading) => {
      return {
        items,
        loading,
      }
    },
  )

@timdeschryver
Copy link
Member

timdeschryver commented Feb 22, 2021

I also tried this locally, and it seems like to be working here. (It took a while for the Angular Service Language to be ready though)
image

This is on VSCode, with the experimental feature activated

image

That being said, I do see some differences with inline templates vs html templates 🤯

image

@timdeschryver
Copy link
Member

Is this still the case @beeman ?

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

No branches or pull requests

3 participants