Skip to content

Commit c48eb64

Browse files
committed
Fix ts issue with core swapping
1 parent f62a415 commit c48eb64

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shopify/flash-list",
3-
"version": "2.0.0-alpha.1",
3+
"version": "2.0.0-alpha.2",
44
"keywords": [
55
"react-native",
66
"recyclerview",

Diff for: src/index.ts

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
import { RecyclerView } from "./recyclerview/RecyclerView";
2-
import LegacyFlashList from "./FlashList";
1+
import { default as OriginalFlashList } from "./FlashList";
32
import { isNewCoreEnabled } from "./enableNewCore";
3+
import { RecyclerView } from "./recyclerview/RecyclerView";
44

5-
const FlashList = (isNewCoreEnabled()
6-
? RecyclerView
7-
: LegacyFlashList) as unknown as typeof LegacyFlashList;
8-
9-
export { FlashList };
5+
// Keep this unmodified for TS type checking
6+
export { default as FlashList } from "./FlashList";
107
export {
118
FlashListProps,
129
ContentStyle,
@@ -54,3 +51,14 @@ export { default as CellContainer } from "./native/cell-container/CellContainer"
5451
export { RecyclerView } from "./recyclerview/RecyclerView";
5552
export { RecyclerViewProps } from "./recyclerview/RecyclerViewProps";
5653
export { useRecyclerViewContext } from "./recyclerview/RecyclerViewContextProvider";
54+
55+
// @ts-ignore - This is ignored by TypeScript but will be present in the compiled JS
56+
// In the compiled JS, this will override the previous FlashList export with a conditional one
57+
if (typeof module !== "undefined" && module.exports) {
58+
Object.defineProperty(module.exports, "FlashList", {
59+
get: function () {
60+
return isNewCoreEnabled() ? RecyclerView : OriginalFlashList;
61+
},
62+
configurable: true,
63+
});
64+
}

0 commit comments

Comments
 (0)