Skip to content

Changing IconProps to a type-only export breaks compatibility with NativeWind and other augmentation-based solutions #62

@kirstilynn

Description

@kirstilynn

Hello,

I recently encountered an issue after updating to version 2.2.0, where IconProps was changed to a type-only export (e.g., export { type IconProps }). This change makes it impossible to augment IconProps via declare module, breaking compatibility with libraries like NativeWind that rely on augmenting component props to add features like className support.

Problem:
In versions prior to 2.2.0, where IconProps was an interface, I was able to extend it using a TypeScript module augmentation:

import type { IconProps as DefaultIconProps } from 'phosphor-react-native';

declare module 'phosphor-react-native' {
  export interface IconProps extends DefaultIconProps {
    className?: string;
  }
}

However, starting with version 2.2.0, the change to:
export { type Icon, type IconProps, IconContext, type IconWeight } from './lib';
no longer allows IconProps to be augmented, as type-only exports cannot participate in module augmentation. This limitation means it is no longer possible to add properties like className to IconProps in a scalable way.

Impact:

This change breaks compatibility with libraries like NativeWind, which are widely used in the React Native ecosystem. Specifically:

  • NativeWind relies on adding className to component props for applying Tailwind classes.
  • The inability to augment IconProps means developers must resort to alternative solutions, which are less efficient and scalable in larger projects.

Proposed Solution:

  • Revert the export of IconProps back to an interface or a non-type-only export so that it can be augmented.

export { Icon, IconProps, IconContext, IconWeight } from './lib';

This change would restore compatibility with module augmentation without affecting existing functionality.

Request:

Please consider reverting IconProps back to a form that can be augmented or provide an alternative solution that allows seamless integration with libraries like NativeWind. Thank you for your consideration!

Supporting Details:
Library version: 2.2.0 (where the change was introduced)
Related libraries: NativeWind

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions