TypeScript 4.4 introduced a new compiler option exactOptionalPropertyTypes that fixes some weak typings by differentiating between undefined and "not present" which results in type errors when passing undefined values to tippy's Partial<Props>.
I found this piece of code in src/createTippy.ts which takes care of the undefined props by using removeUndefinedProps onto the passed props:
That means that we should probably allow undefined as a prop value by adjusting the type of Props because all undefined prop values get stripped away by removeUndefinedProps anyway. Something like this maybe:
type OptionallyUndefined<T> = { [K in keyof T]: T[K] | undefined };
type PassedProps = Partial<OptionallyUndefined<Props>>;
This is how it looks if the exactOptionalPropertyTypes flag is enabled:
Problem
TypeScript 4.4 introduced a new compiler option
exactOptionalPropertyTypes
that fixes some weak typings by differentiating betweenundefined
and "not present" which results in type errors when passingundefined
values to tippy'sPartial<Props>
.I found this piece of code in
src/createTippy.ts
which takes care of theundefined
props by usingremoveUndefinedProps
onto the passed props:Solution
That means that we should probably allow
undefined
as a prop value by adjusting the type ofProps
because allundefined
prop values get stripped away byremoveUndefinedProps
anyway. Something like this maybe:This is how it looks if the
exactOptionalPropertyTypes
flag is enabled: