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 top-level type definition for DayPickerInput #762

Merged
merged 1 commit into from
Aug 25, 2018
Merged

Add top-level type definition for DayPickerInput #762

merged 1 commit into from
Aug 25, 2018

Conversation

kryops
Copy link
Contributor

@kryops kryops commented Jul 29, 2018

This allows importing from 'react-day-picker/DayPickerInput' from TypeScript.
Fixes #586

I chose to keep the existing type definitions for DayPickerInput in the types folder and only reference them from the new top-level definition file. Alternatively, the existing definition file could be moved up to the top level as well, but this would be a breaking change for TypeScript consumers.

The new file also takes care of exporting the DayPickerInput correctly as default export (see #586 (comment))

This allows importing from 'react-daypicker/DayPickerInput' from TypeScript.
Fixes #586
@codecov
Copy link

codecov bot commented Jul 29, 2018

Codecov Report

Merging #762 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #762   +/-   ##
=======================================
  Coverage   99.84%   99.84%           
=======================================
  Files          15       15           
  Lines         645      645           
  Branches      141      141           
=======================================
  Hits          644      644           
  Misses          1        1

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bb771db...1eecd04. Read the comment docs.

@tomalexhughes
Copy link

@gpbl Any chance of this being merged? :)

@nucleartux
Copy link

@gpbl please merge, without this PR I can't use this library on my current project :(

@kryops
Copy link
Contributor Author

kryops commented Aug 24, 2018

@nucleartux you should be able to add the typings manually as a workaround.

  1. Add a file containing the type definition to a folder that you use for types (e.g. src/@types):

[src/@types/react-day-picker.d.ts]

declare module 'react-day-picker/DayPickerInput' {
    import { DayPickerInput } from 'react-day-picker/types/DayPickerInput'
    export default DayPickerInput
}
  1. Add the directory to typeRoots in your tsconfig.json:
"typeRoots": ["node_modules/@types", "src/@types"],

@gpbl gpbl merged commit d616361 into gpbl:master Aug 25, 2018
@gpbl gpbl added this to the v7.2.0 milestone Aug 27, 2018
@nnic
Copy link

nnic commented Aug 29, 2018

This file does not seem to be present in the the npm module - does it need to be explicitly added to the package.json?

@kryops
Copy link
Contributor Author

kryops commented Aug 29, 2018

@nnic sorry my bad 😞
I created #784 to add it.

kimamula pushed a commit to kimamula/react-day-picker that referenced this pull request Aug 17, 2022
Add top-level type definition for DayPickerInput
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