You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow passing undefined to component props with exactOptionalPropertyTypes
The TypeScript configuration option exactOptionalPropertyTypes is
documented at:
https://www.typescriptlang.org/tsconfig/#exactOptionalPropertyTypes
> With exactOptionalPropertyTypes enabled, TypeScript applies stricter
> rules around how it handles properties on type or interfaces which
> have a ? prefix.
This means TypeScript will handle "undefined" differently than "not
provided". Consider the following construct:
```jsx
function MyIcon({ addCLass: false }) {
let className: string | undefined;
if (addClass) {
className = "mx-2";
}
return <FontAwesomeIcon icon={["fal", "coffee"]} className={className}/>
}
```
In this scenario, classname will sometimes be passed as "undefined".
This is allowed by the implementation, so allow it through the type
interface as well.
0 commit comments