1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
//// [mappedTypeUnionConstraintInferences.ts]
export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export declare type PartialProperties<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
export function doSomething_Actual<T extends {
prop: string;
}>(a: T) {
const x: { [P in keyof PartialProperties<T, "prop">]: PartialProperties<T, "prop">[P]; } = null as any;
return x;
}
export declare function doSomething_Expected<T extends {
prop: string;
}>(a: T): { [P in keyof PartialProperties<T, "prop">]: PartialProperties<T, "prop">[P]; };
export let a = doSomething_Actual({ prop: "test" });
a = {} // should be fine, equivalent to below
export let b = doSomething_Expected({ prop: "test" });
b = {} // fine
//// [mappedTypeUnionConstraintInferences.js]
"use strict";
exports.__esModule = true;
function doSomething_Actual(a) {
var x = null;
return x;
}
exports.doSomething_Actual = doSomething_Actual;
exports.a = doSomething_Actual({ prop: "test" });
exports.a = {}; // should be fine, equivalent to below
exports.b = doSomething_Expected({ prop: "test" });
exports.b = {}; // fine
//// [mappedTypeUnionConstraintInferences.d.ts]
export declare type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
export declare type PartialProperties<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
export declare function doSomething_Actual<T extends {
prop: string;
}>(a: T): { [P in keyof PartialProperties<T, "prop">]: PartialProperties<T, "prop">[P]; };
export declare function doSomething_Expected<T extends {
prop: string;
}>(a: T): {
[P in keyof PartialProperties<T, "prop">]: PartialProperties<T, "prop">[P];
};
export declare let a: {
prop?: string;
};
export declare let b: {
prop?: string;
};
|