Skip to content

Commit

Permalink
Merge pull request #79 from Flipkart/typescriptFixes
Browse files Browse the repository at this point in the history
Fixed incorrect type inference in Default.value
  • Loading branch information
muskeinsingh authored Nov 21, 2017
2 parents 63f7b6a + 6552cd9 commit 396b2cf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"dependencies": {
"lodash-es": "4.17.4",
"prop-types": "15.5.8",
"ts-object-utils": "0.0.4"
"ts-object-utils": "0.0.5"
},
"peerDependencies": {
"react": ">= 15.2.1",
Expand Down
2 changes: 1 addition & 1 deletion src/core/RecyclerListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ export default class RecyclerListView extends React.Component<RecyclerListViewPr
const windowBound = this.props.isHorizontal ? layout.width - this._layout.width : layout.height - this._layout.height;
const viewabilityTracker = this._virtualRenderer.getViewabilityTracker();
const lastOffset = viewabilityTracker ? viewabilityTracker.getLastOffset() : 0;
if (windowBound - lastOffset <= Default.value(this.props.onEndReachedThreshold, 0)) {
if (windowBound - lastOffset <= Default.value<number>(this.props.onEndReachedThreshold, 0)) {
if (!this._onEndReachedCalled) {
this._onEndReachedCalled = true;
this.props.onEndReached();
Expand Down
12 changes: 7 additions & 5 deletions src/core/VirtualRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,16 @@ export default class VirtualRenderer {
public getInitialOffset(): Point {
let offset = { x: 0, y: 0 };
if (this._params) {
const initialRenderIndex = Default.value(this._params.initialRenderIndex, 0);
const initialRenderIndex = Default.value<number>(this._params.initialRenderIndex, 0);
if (initialRenderIndex > 0 && this._layoutManager) {
offset = this._layoutManager.getOffsetForIndex(initialRenderIndex);
this._params.initialOffset = this._params.isHorizontal ? offset.x : offset.y;
} else {
if (this._params.isHorizontal) {
offset.x = Default.value(this._params.initialOffset, 0);
offset.x = Default.value<number>(this._params.initialOffset, 0);
offset.y = 0;
} else {
offset.y = Default.value(this._params.initialOffset, 0);
offset.y = Default.value<number>(this._params.initialOffset, 0);
offset.x = 0;
}
}
Expand All @@ -172,7 +172,9 @@ export default class VirtualRenderer {
this.getInitialOffset();
this._recyclePool = new RecycleItemPool();
if (this._params) {
this._viewabilityTracker = new ViewabilityTracker(Default.value(this._params.renderAheadOffset, 0), Default.value(this._params.initialOffset, 0));
this._viewabilityTracker = new ViewabilityTracker(
Default.value<number>(this._params.renderAheadOffset, 0),
Default.value<number>(this._params.initialOffset, 0));
} else {
this._viewabilityTracker = new ViewabilityTracker(0, 0);
}
Expand Down Expand Up @@ -202,7 +204,7 @@ export default class VirtualRenderer {
this._viewabilityTracker.setDimensions({
height: this._dimensions.height,
width: this._dimensions.width,
}, Default.value(this._params.isHorizontal, false));
}, Default.value<boolean>(this._params.isHorizontal, false));
} else {
throw new CustomError(RecyclerListViewExceptions.initializationException);
}
Expand Down

0 comments on commit 396b2cf

Please sign in to comment.