fix: inline FlashListProps to remove @shopify/flash-list type dependency#2620
Open
YevheniiKotyrlo wants to merge 1 commit intogorhom:masterfrom
Open
fix: inline FlashListProps to remove @shopify/flash-list type dependency#2620YevheniiKotyrlo wants to merge 1 commit intogorhom:masterfrom
YevheniiKotyrlo wants to merge 1 commit intogorhom:masterfrom
Conversation
The published BottomSheetFlashList.d.ts unconditionally imports from @shopify/flash-list, but flash-list is not declared in any dependency field. Consumers who don't install flash-list get TS2307 because TypeScript strips @ts-ignore from emitted .d.ts files (by design, confirmed in TypeScript #38628). Replace the external type import with a minimal local interface extending FlatListProps<T> from react-native. The runtime try/catch require('@shopify/flash-list') is unchanged -- only types are affected. Fixes gorhom#2390
|
This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
Contributor
Author
|
@gorhom — friendly bump. This fixes a real TypeScript breakage for consumers who don't install All quality gates pass (tsc, biome lint, bob build). Happy to address any feedback. |
TwanLuttik
added a commit
to TwanLuttik/react-native-bottom-sheet
that referenced
this pull request
Apr 8, 2026
- Replace deprecated Animated.AnimateProps with AnimatedProps (fixes reanimated v4 compatibility) - Fix onScroll prop being incorrectly omitted from BottomSheetFlatListProps types - Invoke render function children directly instead of as JSX component to avoid unnecessary re-renders - Inline FlashListProps type to remove @shopify/flash-list type dependency Fixes: gorhom#2524, gorhom#2629, gorhom#2636, gorhom#2620
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.
Problem
The published
BottomSheetFlashList.d.tsunconditionally imports from@shopify/flash-list:Since
@shopify/flash-listis not declared independencies,peerDependencies, oroptionalDependencies, consumers who don't install flash-list get:The source has
// @ts-ignoreabove the import, which suppresses the error during this package's build — but TypeScript strips@ts-ignorecomments from emitted.d.tsfiles by design (TypeScript #38628, confirmed "Working as Intended" by Ryan Cavanaugh). The downstream type error was never addressed.Related: #2390, #1968
Fix
I replaced the external type import with a minimal local interface:
This eliminates the external type dependency entirely. The runtime
try/catch require('@shopify/flash-list')is unchanged — only types are affected.The local interface covers all props that consumers of
BottomSheetFlashListrealistically use (data,renderItem,keyExtractor, list header/footer components,onEndReached,refreshing,horizontal,numColumns,extraData, plusestimatedItemSize). The few flash-list-specific props omitted (getItemType,overrideItemLayout,drawDistance) are niche optimization hints. For consumers who have@shopify/flash-listinstalled, Metro resolves the real types from the package directly.This is the same pattern used by ts-jest PR #3147 to solve the identical problem with an optional
esbuilddependency.Alternatives I explored
Optional peer dependency — does not work
Adding
@shopify/flash-listtopeerDependenciesMeta: { optional: true }tells the package manager not to warn, but TypeScript does not consultpeerDependenciesMetaduring module resolution. The.d.tsstill imports from@shopify/flash-list, andtscstill fails with TS2307.Separate entry point — correct but disproportionate
Moving
BottomSheetFlashListto a subpath export (@gorhom/bottom-sheet/flash-list) so the main entry point never loads its.d.ts— the Jotai pattern. This works but is a breaking change for existing consumers and restructures exports for a deprecated component.Validation
yarn typescript(tsc --skipLibCheck --noEmit)yarn lint(biome)@ts-ignore)bob build+copy-dts.d.tshas no@shopify/flash-listimporttry/catch require('@shopify/flash-list')preserved