TypeScript N Optional Properties

JS
S
JavaScript

Typescript 2.9 (old piece of code, maybe helpful not sure)

1type Diff<T extends string, U extends string> = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T];
2type Exclude<T, TExclude> = Partial<Record<Diff<Extract<keyof TExclude, string>, Extract<keyof T, string>>, never>>;
3type CancelledOrAbortedSQSEvent = (CancellationSQSEvent & Exclude<CancellationSQSEvent, AbortSQSEvent>) | (AbortSQSEvent & Exclude<AbortSQSEvent, CancellationSQSEvent>);

Created on 12/5/2021