React-admin: Change TypeScript's name of "Record"

Created on 22 Jul 2020  路  2Comments  路  Source: marmelab/react-admin

Is your feature request related to a problem? Please describe.

No problem. It's just a suggestion.

I found that ra-core is using the name Record on the master branch.
https://github.com/marmelab/react-admin/blob/ecd60f6476a8394bf2bdf5f470713b0b87581777/packages/ra-core/src/types.ts#L17

It conflicts with the same naming UtilityType which provided by TypeScript own. Can we change it?

(About Record in TypeScript doc: https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkt )

So, it's not a critical issue, but a bit confusing to TypeScript users.

Describe the solution you'd like

Change Record and other related naming types to other names, how about Data? or Entity?

Describe alternatives you've considered

We can import Record as an arbitrary name by `import type { Record as AdminRecord } from 'ra-core'

Additional context

I already mentioned the same thing in #4505, but I decided to post it as an issue; https://github.com/marmelab/react-admin/issues/4505#issuecomment-662362962
Thanks to @Tymek.

breaking change enhancement

Most helpful comment

Hi, thanks for opening this issue.

We have been using name registration for a long time, even before TypeScript migration. But you're right, using this name as a type could be confusing for TypeScript users.

We have to think twice before changing or not changing this name because it is a radical change.

Of course, this PR is open for discussion :)

All 2 comments

Hi, thanks for opening this issue.

We have been using name registration for a long time, even before TypeScript migration. But you're right, using this name as a type could be confusing for TypeScript users.

We have to think twice before changing or not changing this name because it is a radical change.

Of course, this PR is open for discussion :)

This would be great, Jetbrains IDE doesn't suggest this package a source to import Record from as it's satisfied by the global TypeScript Record. So beyond being confusing, it's also a bit painful if you're used to the auto-discovery of your IDE.

Was this page helpful?
0 / 5 - 0 ratings