Closed
Description
Update: Please see the second comment, titled "simple repro"
Summary
I'm trying to create type definitions for a mixin object. when doing so I found the following error if one of the mixed types has an index signature.
removing the index signature "fixes" the problem.
TypeScript Version: 3.3.3333
Code
/** helper that returns prop names except those to filter. This helper type is needed to actually remove the prop, as otherwise the prop still exists in the type just as "never". */
type PropsRemove_Name<TTarget, TPropToRemove> = { [ K in keyof TTarget ]: TTarget[ K ] extends TPropToRemove ? never : K }[ keyof TTarget ];
/** remove props of the given type. always removes ```never``` type props. if no ```TPropToRemove``` is provided, removes just ```never``` type props. */
type PropsRemove<TTarget,TPropToRemove=never> = Pick<TTarget, PropsRemove_Name<TTarget,TPropToRemove>>;
/** type used to demonstrate the bug */
type TestType = {
a: number;
} & {
b: boolean;
[ key: string ]: boolean; //THE OFFENDING LINE
}
let testRemoval: PropsRemove<TestType,number>;
Expected behavior:
//expect typescript to provide the proper definition.
testRemoval.b; //boolean
Actual behavior:
//with the index signature, typescript provides no properties in the dropdown
testRemoval; //no properties
//when the index signature is removed, typescript provides the proper definition.
testRemoval.b; //boolean
Related Issues: didn't really see any :(