-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
Bug Report
π Search Terms
omit, mapped type, intersection
π Version & Regression Information
- This is the behavior in every version I tried, 3.5.1 up to 4.9.4
β― Playground Link
Playground link with relevant code
π» Code
type Column = {value: number}
type RemoveTitles<Type> = {
[Property in keyof Type]: Omit<Type[Property], 'title'>;
};
class TableDataGenerator2<
TIn extends { [colName: string]: Column & { title: string } },
TAdd extends { [colName: string]: Column & { title: string } } = {}
> {
constructor(
private callback: (
index: number,
row: RemoveTitles<TIn>
) => Promise<RemoveTitles<TAdd>>
) {}
chain<TAdd2 extends { [colName: string]: Column & { title: string } }>(
cb: (
index: number,
row: RemoveTitles<TIn> & RemoveTitles<TAdd>
) => Promise<RemoveTitles<TAdd2>>
): TableDataGenerator2<TIn, TAdd & TAdd2> {
return new TableDataGenerator2<TIn, TAdd & TAdd2>(async (index, input) => {
const elem = await this.callback(index, input);
const elem2 = await cb(index, { ...elem, ...input });
return { ...elem2, ...elem };
});
}
}
Argument of type '(index: number, input: RemoveTitles<TIn>) => Promise<RemoveTitles<TAdd2> & RemoveTitles<TAdd>>' is not assignable to parameter of type '(index: number, row: RemoveTitles<TIn>) => Promise<RemoveTitles<TAdd & TAdd2>>'.
Type 'Promise<RemoveTitles<TAdd2> & RemoveTitles<TAdd>>' is not assignable to type 'Promise<RemoveTitles<TAdd & TAdd2>>'.
Type 'RemoveTitles<TAdd2> & RemoveTitles<TAdd>' is not assignable to type 'RemoveTitles<TAdd & TAdd2>'.
π Actual behavior
TypeScript does not detect that RemoveTitles<T1> & RemoveTitles<T2> is compatible with RemoveTitles<T1 & T2>
π Expected behavior
RemoveTitles<T1> & RemoveTitles<T2> is compatible with RemoveTitles<T1 & T2> and should be treated as equivalent, as can be seen in this example
Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed