Repository navigation
refactor: make Swift forward-declaration collection polymorphic (#1846) - #2020
Open
dhruvpatel374 wants to merge 1 commit into
Open
dhruvpatel374 wants to merge 1 commit into
dhruvpatel374 wants to merge 1 commit into
Conversation
…elo#1846) Move the knowledge of how to produce a Swift-Cxx forward declaration out of two identical caller-side type-checks and into HybridObjectType itself via an optional Type interface method. Before: both createSwiftCxxBridge and createSwiftUmbrellaHeader had to independently check `kind === 'hybrid-object'`, cast with getTypeAs, and reconstruct the same getForwardDeclaration call. After: HybridObjectType implements getForwardDeclarations() once. Both callers collapse to flatMap(t => t.getForwardDeclarations?.() ?? []). Any future type that needs Swift forward declarations just implements the method — callers do not change. Also fixes a pre-existing TypeScript error in createSwiftCxxBridge where .filter((b) => b != null) did not narrow the type, causing b?.dependencies to spread undefined. Replaced with a proper type-guard predicate. Generated output is identical — confirmed with bun specs (zero diff on all generated files). Typecheck and all offline tests pass.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1846 — implements Option 3 (the standalone cleanup) only.
What
Two files (
createSwiftCxxBridgeandcreateSwiftUmbrellaHeader) hadidentical 6-line blocks that checked
kind === 'hybrid-object', castwith
getTypeAs, and reconstructed the samegetForwardDeclarationcall. That is exactly the "checking for concrete type classes at
callers" that Option 3 of #1846 describes.
This moves the knowledge into
HybridObjectTypevia an optional methodon the
Typeinterface: