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

Improve TypeScript Utility Types #21

Open
gwansikk opened this issue Aug 19, 2024 · 6 comments
Open

Improve TypeScript Utility Types #21

gwansikk opened this issue Aug 19, 2024 · 6 comments
Labels
good first issue Good for newcomers

Comments

@gwansikk
Copy link

Hello! I came across an interesting open-source project and wanted to share my thoughts.

In existing utility types like Omit or Pick, the Key part doesn't support auto-completion, which can be inconvenient. How about improving these utility types to enhance usability?

Below is an example of Omit. By using OmitKeyof, you can make it more convenient with auto-completion.

image
@haejunejung
Copy link
Owner

haejunejung commented Aug 19, 2024

Thank you for sharing your idea.

I found your approach to enhancing utility types like Omit or Pick through OmitKeyof to be very practical. The idea of improving developer experience by adding auto-completion is particularly impressive.

Additionally, by incorporating auto-completion, your solution helps catch potential developer mistakes early, reducing the likelihood of typos and improving code accuracy.

@haejunejung
Copy link
Owner

Hello, @gwansikk.,

I am concerned about which naming would be most appropriate for this stricter version. I think OmitKeyof can be thought of as extracting a key like using the keyof operator, and I think its relationship with keyof may be somewhat unclear. The result is in the form of an object, but I thought it could be thought of as extracting keys excluding a specific key.

After checking the TypeScript issue, microsoft/TypeScript#30825, I think it would be better to define it as a new word rather than using the word Strict. Like Except. What do you think?

@gwansikk
Copy link
Author

I think it would be better to define it as a new word rather than using the word Strict. Like Except. What do you think?

I agree. This is an extension of the Omit DX, and the name OmitKeyof isn't quite fitting. A more appropriate name is needed.

@haejunejung
Copy link
Owner

As a result of my search, I found that StrictOmit is commonly used in other libraries. So, although Strict is said to be ambiguous in terms of TypeScript issues, I think it is appropriate to use it.

I think StrictOmit, Except, and OmitByKey are suitable, but I would like to hear your opinion on which one is most suitable.

@gwansikk
Copy link
Author

I think StrictOmit, Except, and OmitByKey are suitable, but I would like to hear your opinion on which one is most suitable.

I think StrictOmit would be appropriate. It's used in other similar libraries and is widely recognized, which could make ts-typekit easier to understand or migrate to.

However, this is just my opinion. If we use the Strict prefix, it would make sense to use it for other utility types as well (e.g., StrictPick), so I suggest carefully considering this before making a decision.

@haejunejung
Copy link
Owner

haejunejung commented Aug 23, 2024

I think StrictOmit would be appropriate. It's used in other similar libraries and is widely recognized, which could make ts-typekit easier to understand or migrate to.

However, this is just my opinion. If we use the Strict prefix, it would make sense to use it for other utility types as well (e.g., StrictPick), so I suggest carefully considering this before making a decision.

I agree with your comment 👌.

When we use StrictOmit, the strict version of other built in utility types such as Extract is needed. Thank you for helpul opinion:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants