Skip to content
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

Add TS types definitions #86

Merged
merged 3 commits into from
Dec 22, 2017

Conversation

krzysztofciombor
Copy link

Description

Adds TypeScript types definitions.
See also: #78

Test plan

The TS types are correctly picked up when importing Gesture Handlers inside *.ts file:
zrzut ekranu 2017-12-19 o 17 17 25
zrzut ekranu 2017-12-19 o 17 17 34

"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"precommit": "lint-staged"
},
"main": "GestureHandler.js",
"types": "react-native-gesture-handler.d.ts",
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs to be added to "files" section too

@kmagiera kmagiera merged commit 69d414e into software-mansion:master Dec 22, 2017
@kmagiera kmagiera mentioned this pull request Dec 22, 2017
@krzysztofciombor krzysztofciombor deleted the ts-types branch December 22, 2017 13:52
@brunolemos
Copy link
Contributor

brunolemos commented Dec 23, 2017

@krzysztofciombor thanks for the typings!

It works if I import like this: import { Swipeable } from 'react-native-gesture-handler'
But not if I import like this: import Swipeable from 'react-native-gesture-handler/Swipeable'

Also maybe we should add types for the instances too, if possible?
E.g. I can call swipeableRef.close() and other methods but that doesn't autocomplete.

image

@brunolemos
Copy link
Contributor

#87 should fix it

@brunolemos
Copy link
Contributor

I get this on RectButton and don't know why:

[ts] Property 'style' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<RectButton> & Readonly<{ children?: ReactNode; }> ...'.
(JSX attribute) style: ((number & {
    __registeredStyleBrand: ViewStyle | TextStyle | ImageStyle;
}) | {
    backgroundColor: string;
    width: number | undefined;
})[]

image

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.

3 participants