platform icon indicating copy to clipboard operation
platform copied to clipboard

UpdateStr and UpdateNum are not export in index

Open muuvmuuv opened this issue 1 year ago • 2 comments

Which @ngrx/* package(s) are the source of the bug?

entity

Minimal reproduction of the bug/regression with instructions

Does not work: import { UpdateStr } from '@ngrx/entity' Works but errors: import { UpdateStr } from '@ngrx/entity/src/models'

Expected behavior

Export it like Update.

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

Just updated to latest

Other information

No response

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

  • [ ] Yes
  • [X] No

muuvmuuv avatar Jun 04 '24 05:06 muuvmuuv

Could you please elaborate the use case why these types are required over Update<T>?

timdeschryver avatar Jun 05 '24 14:06 timdeschryver

We put in some models directly that come from our API, these have strings as their ID. To not always call .toString() it would be nice to directly say UpdateStr. TypeScript will always complain about it when doing stuff like entry.id === id, because it could be a number.

function patchEntryAndChildrens(entry: Update<Entry>) {
  // ... update
  const children = state.filter(e => e.parentId === entry.id.toString()) // id/parentId are strings
}

muuvmuuv avatar Jun 05 '24 14:06 muuvmuuv