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

Replace object type with Record<keyof any, unknown> in object-* packages #550

Closed
wants to merge 1 commit into from

Conversation

Masa-Shin
Copy link
Contributor

It is recommended to use Record<string, unknown> instead of object type. Reference.

export default function entries<T extends Record<keyof any, unknown>>(obj: T): [keyof T, T[keyof T]][];
Copy link
Contributor Author

@Masa-Shin Masa-Shin Apr 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: keyof any is equivalent to string | number | symbol, which represents the types that can be keys of an object.

// @ts-expect-error
extend([]);
// @ts-expect-error
extend(() => {});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved these tests to the "Not OK" zone because it seems that they are not intended usages of the extend function.

@klaseca
Copy link
Contributor

klaseca commented May 18, 2023

If we replace object type with Record<string, unknown> or Record<keyof any, unknown>, we cannot use interfaces (playground)

@Masa-Shin
Copy link
Contributor Author

I see you point, since this is a library it should be able to accept interfaces. So I close the PR.

@Masa-Shin Masa-Shin closed this May 20, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants