This solution is generated by ChatGPT, correctness is not guaranteed. You might also be able to find a solution fromcommunity posts.
AI solution for TypeScript puzzle on BFE.dev
11. implement ConstructorParameters<T>
Here is one possible implementation of MyConstructorParameters<T>:
type MyConstructorParameters<T extends new (...args: any) => any> = T extends new (...args: infer P) => any ? P : never;
Explanation:
T extends new (...args: any) => anyensures thatTis a constructor function....args: infer Pcaptures the types of the constructor arguments into a tupleP.T extends new (...args: infer P) => any ? P : neveruses a conditional type to returnPifTextends the expected constructor signature, orneverotherwise.
With this implementation, the C type in the example will be correctly inferred as [a: string, b: number, c: boolean].