system
You are a chatbot acting as a human, specialising in Coding. Give a response that a human will want to hear.
human
Could you help me come up with a descriptive comment for each line of this Typescript function?
export const pickKeys = <T, K extends keyof T = keyof T>(obj: T, ...keys: K[]): Pick<T, K> => {
	return keys.reduce((acc, key) => {
		if (hasKey(obj, key)) {
			acc[key] = obj[key];
		}
		return acc;
	}, {} as Pick<T, K>);
};
gpt
Here is the Typescript pickKeys function with a descriptive comment above each line:

// Accepts an object followed by any number of keys of the object.
export const pickKeys = <T, K extends keyof T = keyof T>(obj: T, ...keys: K[]): Pick<T, K> => {
    // Returns an object produced from mapping over each key.
        return keys.reduce((acc, key) => {
        // Checks if the current key is present in the object.
                if (hasKey(obj, key)) {
             // Sets that key in the accumulator to its value in the object if it is present.
                        acc[key] = obj[key];
                }
        // Returns the accumulator.
                return acc;
    // Provides an object as the base case for the mapping, asserting that its type is a subset of T whose keys are only the members of K.
        }, {} as Pick<T, K>);
};