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

[Feature]: add example with usage of both keyof & typeof operators #1307

Open
reznikovAndrey opened this issue Dec 10, 2023 · 3 comments
Open
Labels
documentation Improvements or additions to documentation enhancement New feature or request

Comments

@reznikovAndrey
Copy link

reznikovAndrey commented Dec 10, 2023

Description

I think it's necessary to provide example with usage of both keyof & typeof operators.
The final solution like this will be more clear.
Снимок экрана 2023-12-11 в 01 46 49

Explanation

In my opinion, after completing challenge with usage of keyof operator newcomer might think, that provided examples are only valid way of using keyof.

In other words:

  1. You create new type with typeof.
  2. You need use keyof with this type.

But in real world there are a lot of examples of using both keyof & typeof operators together.
I consider this as best practice.

@reznikovAndrey reznikovAndrey added enhancement New feature or request triage labels Dec 10, 2023
@bautistaaa
Copy link
Member

bautistaaa commented Dec 10, 2023

these are meant to be taken in order when you enroll in the foundations track. typeof is a challenge before you encounter keyof. perhaps we should remove these from the explore page and point them to the track

@bautistaaa
Copy link
Member

bautistaaa commented Dec 10, 2023

i also don’t understand the best practice part of your comment. the pref would usually be typeof standalone so you can reuse the type and making a separate type if you needed the union

of course this is situational

@reznikovAndrey
Copy link
Author

Yeah, you are right, that's situational.
My fault, it's not best practice.

At least may be it would be better to have explicit example of usage of this operators together?

Снимок экрана 2023-12-11 в 14 35 59

@jhechtf jhechtf added documentation Improvements or additions to documentation and removed triage labels Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

3 participants