-
Notifications
You must be signed in to change notification settings - Fork 205
Add typescript definition file #35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
layout: { x: number; y: number; width: number; height: number }; | ||
}; | ||
}) => void; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type LayoutRectangle
could be imported from react-native and then this could be changed to:
declare function useLayout(): LayoutRectangle & {
onLayout: (event: {
nativeEvent: {
layout: { x: number; y: number; width: number; height: number };
};
}) => void;
};
Good catch. Updated to use that type both in the |
@jnpdx That's even better 😄 |
Since export interface DeviceOrientation {
portrait?: boolean
landscape?: boolean
}
declare function useDeviceOrientation(): DeviceOrientation |
New suggestions from @marnusw implemented |
Why is this PR not merged ? |
I'm guessing people are waiting for a move to typescript? We should merge this anyway until this happens. Also I started a PR for a move to typescript and I would appreciate people's help there so we can finish quicker. |
Closing this. Now that we moved to TS, this is generated. Thanks everyone for the input and help! |
Summary
This adds an
index.d.ts
Typescript definition file to the project. The typings are taken either directly from Typescript's inferences of the functions or from React Native's types via@types/react-native
This adds out-of-the-box Typescript support. Note that it does depend on @types/react-native, although I did not add this to
peerDependencies
since only Typescript users need this and would obviously have it installed already.Test Plan
What's required for testing (prerequisites)?
Add
react-native-hooks
to a Typescript enabled React Native project.What are the steps to reproduce (after prerequisites)?
Typings should be available with all of the same syntax/usage as before.
Compatibility
Checklist
README.md
CHANGELOG.md
example/App.js
)