Skip to content

Commit 4a26bf3

Browse files
authored
fix(types): fix some RA input props cannot be used as InputGuesser props (#644)
1 parent e58c108 commit 4a26bf3

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/types.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -492,14 +492,18 @@ export type IntrospectedInputGuesserProps = Partial<InputProps> &
492492
'filter' | 'page' | 'perPage' | 'sort' | 'enableGetChoices'
493493
>;
494494

495-
export type InputGuesserProps = Omit<
495+
// Thanks Tkdodo!
496+
// https://tkdodo.eu/blog/omit-for-discriminated-unions-in-type-script#distributive-omit
497+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
498+
export type DistributiveOmit<T, K extends keyof T> = T extends any
499+
? Omit<T, K>
500+
: never;
501+
502+
export type InputGuesserProps = DistributiveOmit<
496503
InputProps & Omit<BaseIntrospecterProps, 'resource'>,
497504
'component'
498505
> & {
499506
transformEnum?: (value: string | number) => string | number;
500-
// due to the union type some TextInputProps don't surface in the final type, re-adding them here
501-
multiline?: boolean;
502-
readOnly?: boolean;
503507
} & Pick<
504508
ReferenceInputProps | ReferenceArrayInputProps,
505509
'filter' | 'page' | 'perPage' | 'sort' | 'enableGetChoices'

0 commit comments

Comments
 (0)