Skip to content

fix: allow children on web Defs - #3056

Merged
jakex7 merged 1 commit into
software-mansion:mainfrom
roryabraham:rory/web-defs-children
Sep 11, 2026
Merged

jakex7 merged 1 commit into
software-mansion:mainfrom
roryabraham:rory/web-defs-children

Conversation

@roryabraham

Copy link
Copy Markdown
Contributor

Summary

Web Defs did not declare children on its props generic, so TypeScript consumers that resolve .web first (e.g. moduleSuffixes: [".web", ""]) rejected <Defs>{children}</Defs>.

This showed up in Expensify App: Expensify/App#99495

Native Defs (src/elements/Defs.tsx) is Component<React.PropsWithChildren>. Sibling web classes (G, Mask, Symbol, ClipPath, etc.) already pass WebShape<BaseProps & XProps>. Web Defs was the only one extending bare WebShape.

Implementation: export class Defs extends WebShape<PropsWithChildren<BaseProps>> in src/elements.web.ts. Types-only; no runtime change.

Impact: web TypeScript declarations only.

Test Plan

Type-only; no device or simulator test.

With moduleSuffixes: [".web", ""], tsc should accept:

<Defs>
  <Filter />
</Defs>

What's required for testing (prerequisites)?

TypeScript consumer that resolves react-native-svg via .web suffixes.

What are the steps to reproduce (after prerequisites)?

  1. Use <Defs> with children against the web declaration.
  2. Confirm tsc no longer errors that children is not a valid prop.

Compatibility

OS Implemented
iOS ❌
MacOS ❌
Android ❌
Web ✅

Types-only web.

Checklist

  • I have tested this on a device and a simulator
  • I added documentation in README.md
  • I updated the typed files (typescript)
  • I added a test for the API in the __tests__ folder

Native Defs is PropsWithChildren. The web class extended bare WebShape,
so moduleSuffixes [".web", ""] rejected <Defs> children.

@jakex7 jakex7 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants