Bug Report
🔎 Search Terms
🕗 Version & Regression Information
In typecript generated type (d.ts) they is an error while using Required in [K in keyof Required<T>] in a arrow function definition
- This changed between versions 4.6.4 and newer version of typescript
⏯ Playground Link
https://www.typescriptlang.org/play?jsx=0&ts=4.6.4#code/KYDwDg9gTgLgBAYwgOwM7xsdAmOBeOAHgBV84AlYJKAE0PSgEtkBzAGjmWADdgoA+fgApUCABbAAtgEMAXHADeAKDiq4AbQDScZnADWwAJ4QAZhWABHAK6MowOsX4BdecS1OA3EoC+ASnz8iipqSGgQADbAAHThECwi4lLSvl7eSkqgkLBwJlbICDCMKHCY6ACMJGSU1HQMzOycPHyCCRIy8spqGtq6BsZmlNa29iTOru6p-p0hKKgR0bHxom3JqR5AA
💻 Code
export const test2 = <T = Record<string, never>>(schema: {
[K in keyof Required<T>]: T[K];
}) => {
console.log(schema);
}
export function test1<T = Record<string, never>>(schema: {
[K in keyof Required<T>]: T[K];
}) {
console.log(schema);
};
🙁 Actual behavior
In typescript 4.6.4 the d.ts file look like this:
export declare const test2: <T = Record<string, never>>(schema: { [K in keyof Required<T>]: T[K]; }) => void;
export declare function test1<T = Record<string, never>>(schema: {
[K in keyof Required<T>]: T[K];
}): void;
And starting from 4.7 the d.ts file look like this:
export declare const test2: <T = Record<string, never>>(schema: Required<T> extends infer T_1 ? { [K in keyof T_1]: T[K]; } : never) => void;
export declare function test1<T = Record<string, never>>(schema: {
[K in keyof Required<T>]: T[K];
}): void;
🙂 Expected behavior
This should be compiled to the same output as the 4.6 version
Bug Report
🔎 Search Terms
🕗 Version & Regression Information
In typecript generated type (d.ts) they is an error while using
Requiredin[K in keyof Required<T>]in a arrow function definition⏯ Playground Link
https://www.typescriptlang.org/play?jsx=0&ts=4.6.4#code/KYDwDg9gTgLgBAYwgOwM7xsdAmOBeOAHgBV84AlYJKAE0PSgEtkBzAGjmWADdgoA+fgApUCABbAAtgEMAXHADeAKDiq4AbQDScZnADWwAJ4QAZhWABHAK6MowOsX4BdecS1OA3EoC+ASnz8iipqSGgQADbAAHThECwi4lLSvl7eSkqgkLBwJlbICDCMKHCY6ACMJGSU1HQMzOycPHyCCRIy8spqGtq6BsZmlNa29iTOru6p-p0hKKgR0bHxom3JqR5AA
💻 Code
🙁 Actual behavior
In typescript 4.6.4 the d.ts file look like this:
And starting from 4.7 the d.ts file look like this:
🙂 Expected behavior
This should be compiled to the same output as the 4.6 version