-
-
Notifications
You must be signed in to change notification settings - Fork 732
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 typescript definitions #303
Conversation
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.
Consider adding dtslint as well. I haven't tried it yet but it looks fairly self-contained (installs typescript & tslint for you) and applicable here.
cc @giladgray
react-day-picker.d.ts
Outdated
// Type definitions for react-day-picker 5.2 | ||
// Project: https://github.com/gpbl/react-day-picker | ||
// Definitions by: Giampaolo Bellavite <https://github.com/gpbl>, Jason Killian <https://github.com/jkillian> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped |
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.
I don't think you need the above 4 lines, just the TypeScript compiler version
package.json
Outdated
@@ -62,6 +62,7 @@ | |||
"peerDependencies": { | |||
"react": "~0.13.x || ~0.14.x || ^15.0.0" | |||
}, | |||
"types": "./react-day-picker.d.ts", |
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.
i'd say this belongs up near main
and style
keys as it's a distributable file
react-day-picker.d.ts
Outdated
React.ComponentClass<WeekdayElementProps> | | ||
React.SFC<WeekdayElementProps>; | ||
weekdaysLong?: [string, string, string, string, string, string, string]; | ||
weekdaysShort?: [string, string, string, string, string, string, string]; |
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.
real game changing feature would be to include /** docs */
on each of these props. i know you have great docs for every prop already... but that could easily be added in a future release.
commit 0dcc6cd Author: Giampaolo Bellavite <gpbellavite@gmail.com> Date: Tue Apr 25 12:30:01 2017 -0500 Remove prop quick reference commit fbc3979 Author: Giampaolo Bellavite <gpbellavite@gmail.com> Date: Tue Apr 25 12:29:38 2017 -0500 Make example’s code cleaner commit 536c8d0 Author: Giampaolo Bellavite <gpbellavite@gmail.com> Date: Tue Apr 25 12:25:08 2017 -0500 Add docs for modifiersStyles commit f96e389 Merge: 17f707e 461d377 Author: Giampaolo Bellavite <io@gpbl.org> Date: Thu Apr 20 11:13:56 2017 -0500 Merge pull request #302 from gpbl/fix-function-modifier Fix function modifiers commit 461d377 Author: Giampaolo Bellavite <gpbellavite@gmail.com> Date: Thu Apr 20 11:02:39 2017 -0500 Add example commit f997d6b Author: Giampaolo Bellavite <gpbellavite@gmail.com> Date: Thu Apr 20 10:59:02 2017 -0500 Accept function in array of modifiers
docs/API.md
Outdated
@@ -1,47 +1,4 @@ | |||
# Component API | |||
|
|||
* [Component props](APIProps.md) | |||
* [Component methods](APIMethods.md) | |||
|
|||
## Props quick reference |
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.
I think you might want to add a link to types/index.d.ts here? People might not know to look for that immediately
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.
Sure 👍🏽 However, aren't the definitions inferred by the tools using them?
PS. thanks @adidahiya @giladgray for the help! I never used TypeScript and I'm happy to learn something new!
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.
not exactly: the tools rely on package.json "types"
key to tell them where to find an entry .d.ts
file, and the node_modules/@types
scope directory to list all the available external modules.
package.json
Outdated
"files": [ | ||
"DayPicker.js", | ||
"lib", | ||
"moment.js", | ||
"utils.js" | ||
"utils.js", | ||
"./types/index.d.ts" |
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.
for consistency i'd omit the ./
but whatever 🚢
(also above in "types"
)
react-day-picker.d.ts
from DefinitelyTypedSee #299 and DefinitelyTyped/DefinitelyTyped#16010