ngrx / platform

Reactive State for Angular
https://ngrx.io
Other
7.95k stars 1.95k forks source link

UpdateStr and UpdateNum are not export in index #4374

Open muuvmuuv opened 1 month ago

muuvmuuv commented 1 month ago

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

timdeschryver commented 4 weeks ago

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

muuvmuuv commented 4 weeks ago

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
}