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

ngrx-slice Can't infer types of selectors when used inside a buildable nx library with @nrwl/angular:webpack-browser executor #2

Open
fatihdogmus opened this issue Apr 22, 2022 · 7 comments

Comments

@fatihdogmus
Copy link

Hello Chau, sorry to bother you again 🙂

I've been trying to migrate our application to support incremental builds with buildable libraries, and been following this tutorial on how to do it: https://nx.dev/ci/setup-incremental-builds-angular

Everything works, except the ngrx-slice selector types are inferred as unknown by typescript on build time, and can't assign them to any variables, giving this error:
image

The project works fine with either serve command or with default executor.

Here is a repo to reproduce: https://github.com/fatihdogmus/ngrx-slice-type-inference-error

Run pnpm install && pnpm build on repo to reproduce

I didn't know where is the problem, ngrx-slice, ngrx or nx itself, but since you are involved with all of them, I thought you could point me to right direction 🙂

Thank you very much.

@nartc
Copy link
Owner

nartc commented Apr 22, 2022

Hey @fatihdogmus , thank you for reporting. To be quite honest, this seems weird. However, to unlock you, I think I can force any from ngrx-slice side instead of unknown since you mention this only happens when build and NOT affecting dev experience. Right?

@fatihdogmus
Copy link
Author

Yes that is correct.

I pinned the problem to "buildLibsFromSource": false . When I remove this setting, build passes. I don't know why though 🙂

Setting it to any might solve the problem. But won't changing it to any be problematic, since it won't be as type safe?

@nartc
Copy link
Owner

nartc commented Apr 22, 2022

@fatihdogmus Not entirely. The type inference should work the same for any / unknown.

@fatihdogmus
Copy link
Author

Sure if you have time, I would be glad to try it 🙂

@nartc
Copy link
Owner

nartc commented Apr 22, 2022

Hey @fatihdogmus , it looks like it can also be an issue with pnpm and how it resolves dependencies (immer in this case). Can you try with yarn or npm on your side to see if the build pass (Without changing anything, just switch package manager)?

@fatihdogmus
Copy link
Author

I really don't like npm package structure 🙂 yes it worked both on the demo repo and in our own actual repo. Thank you for the pointer and your time. I love dealing with obscure problems of package managers on friday 🙂

@nartc
Copy link
Owner

nartc commented Apr 22, 2022

yeah I'm a pnpm user myself :( not sure how to debug this on a Friday haha. I'll reach out to Colum/Leo on our team (they work on incremental build for Angular) and see if they have any idea

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