You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this challenge, you are tasked with creating a type PathValue that will take an object and a string representing the path to a certain value within the object. Your job is to return the type of the value at that path. This will test your skills in generics, conditional types, and type inference.
Here's an example to get you started:
constdata={user: {name: 'Alice',age: 30,address: {city: 'Wonderland'}}}asconst;// The PathValue type should return the type of the value at the specified path.typeUserNameType=PathValue<typeofdata,'user.name'>;// Type: 'Alice'
Template
This is the template for challengers to start the coding. Basically, you just need to change the name of your generic/function and leave to implementation any.
typePathValue<T,Pextendsstring>=any;
Test Cases
Provide some test cases for your challenge, you can use some utils from @type-challenges/utils for asserting.
Info
Basic info of your challenge questions,
Question
In this challenge, you are tasked with creating a type PathValue that will take an object and a string representing the path to a certain value within the object. Your job is to return the type of the value at that path. This will test your skills in generics, conditional types, and type inference.
Here's an example to get you started:
Template
This is the template for challengers to start the coding. Basically, you just need to change the name of your generic/function and leave to implementation
any
.Test Cases
Provide some test cases for your challenge, you can use some utils from
@type-challenges/utils
for asserting.The text was updated successfully, but these errors were encountered: