Skip to content

Conversation

@deregtd
Copy link
Collaborator

@deregtd deregtd commented Sep 18, 2017

  •    "noImplicitReturns": true,
    
  •    "noImplicitThis": true,
    
  •    "noUnusedLocals": true,
    
  •    "strictNullChecks": true,
    
  •    "forceConsistentCasingInFileNames": true,
    

@msftclas
Copy link

@deregtd,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot

type: React.ComponentClass<P>;
props: P;
}
// interface Element<P> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not remove?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It was probably wanted by someone originally. Gets compiled away.

*/

import RN = require('react-native');
//import RN = require('react-native');
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not remove?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When they build this component, they'll want this line back.

protected _getStyles(): Types.TextStyleRuleSet | Types.TextStyleRuleSet[] {
return Styles.combine<Types.TextStyle>([_styles.defaultText, this.props.style]);
protected _getStyles(): Types.StyleRuleSetRecursiveArray<Types.TextStyleRuleSet> {
return _.compact([_styles.defaultText, this.props.style]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you calling compact here? It's fine to have undefined or null values in the styles that are sent to RN.

title?: string;

onLoad?: (size: Dimensions) => void;
onLoad?: (size: OptionalDimensions) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these fields optional? Are there circumstances where RN can't hand back valid dimensions? I'd prefer if these are non-optional. Otherwise it complicates the logic in all components that use this callback.

// IMPORTANT NOTE: This handler may be called when the component is
// already unmounted as it uses a time delay to accommodate a fade-out animation.
onAnchorPressed?: (e: RX.Types.SyntheticEvent) => void;
onAnchorPressed?: (e?: RX.Types.SyntheticEvent) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this parameter optional? Seems like it should be required.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

talked offline

type: React.ComponentClass<P>;
props: P;
}
// interface Element<P> {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is unused, you can delete it.

width: number;
height: number;
};
export type OptionalDimensions = {
Copy link
Contributor

Choose a reason for hiding this comment

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

See note above. I don't think these fields should be optional.


return (timeStamp - initialTimeStamp <= _tapDurationThreshold &&
this._calcDistance(initialPageX - e.pageX, initialPageY - e.pageY) <= _tapPixelThreshold);
this._calcDistance(initialPageX - (e.pageX || 0), initialPageY - (e.pageY || 0)) <= _tapPixelThreshold);
Copy link
Contributor

Choose a reason for hiding this comment

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

For these types of events, we're guaranteed that pageX and pageY are defined. So you could keep the code as is or change it to e.pageX!!!, etc.

onHoverStart={ () => this.setState({ hoverIndex: i }) }
onHoverEnd={ () => this.setState({ hoverIndex: -1 }) }
style={ buttonStyle }
style={ _.compact(buttonStyle) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you compacting these styles? It's perfectly legit for style arrays to contain undefined values.


private _getPanPixelThreshold = () => {
return this.props.panPixelThreshold > 0 ? this.props.panPixelThreshold : _panPixelThreshold;
return (this.props.panPixelThreshold && this.props.panPixelThreshold > 0) ? this.props.panPixelThreshold : _panPixelThreshold;
Copy link
Contributor

Choose a reason for hiding this comment

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

Zero values work OK in this logic, but it would be better if the check for undefined was more explicit.

if (this.props.autoDismiss) {
// Should we immediately hide it, or did the caller request a delay?
if (this.props.autoDismissDelay > 0) {
if (this.props.autoDismissDelay && this.props.autoDismissDelay > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Zero values work OK with this logic, but an explicit undefined type would be better.

getItem(key: string): SyncTasks.Promise<string|undefined> {
const value = window.localStorage.getItem(key);
return SyncTasks.Resolved<string|undefined>(value);
return SyncTasks.Resolved<string|undefined>(value || undefined);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you want to turn empty strings into undefined here? I don't think that's the right semantic.

Copy link
Contributor

@ms-markda ms-markda left a comment

Choose a reason for hiding this comment

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

Nothing seems out of place with respect to the TypeScript transformations. The interface changes seem alright, but you might want another opinion on that.

David de Regt added 2 commits September 18, 2017 16:54
…m. Made the exported reactxp.ts files per-platform export types from the base classes instead of their specific implementation. This brought a bunch of interface holes to the surface.
@deregtd deregtd merged commit fdccce2 into master Sep 19, 2017
@deregtd deregtd deleted the dadere/TSOptions branch September 19, 2017 04:47
berickson1 pushed a commit to berickson1/reactxp that referenced this pull request Oct 22, 2018
…nitions (microsoft#280)

* Rename microsoft#1 for ViewBase to fix caps

* Rename microsoft#2 to fix ViewBase.  Enabling forceConsistentCasingInFileNames.

* Enabling noImplicitReturns, fixing a bug in native-common/Linking.ts

* Enabling noImplicitThis

* Enabling noUnusedLocals and fixing some bugs it found

* Enabling strict null checks on reactxp

* Addressing PR feedback

* Fixing a bunch of type exporting/checking issues

* Fixed a bunch of base interfaces and made everything inherit from them.  Made the exported reactxp.ts files per-platform export types from the base classes instead of their specific implementation.  This brought a bunch of interface holes to the surface.
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.

5 participants