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

Typescript typings have no default export #533

Closed
firsttris opened this issue Oct 29, 2017 · 5 comments · Fixed by #567
Closed

Typescript typings have no default export #533

firsttris opened this issue Oct 29, 2017 · 5 comments · Fixed by #567
Milestone

Comments

@firsttris
Copy link
Contributor

firsttris commented Oct 29, 2017

Holla,
before it was possible to import react-day-picker in typescript using the following construct:

import DayPicker from 'react-day-picker';

In version 6.2.1 the tsc compiler complains that 'react-day-picker' has no default export.

image

but if a change:

// **\node_modules\react-day-picker\types\index.d.ts
// TypeScript Version: 2.2

import { DayPicker } from "./DayPicker";
// We need to use 'export =' to be compatible with the 'module.exports = DayPicker.default || DayPicker' syntax
// in DayPicker.js in the final NPM package.
export = DayPicker;

to

// **\node_modules\react-day-picker\types\index.d.ts
// TypeScript Version: 2.2

import { DayPicker } from "./DayPicker";
// We need to use 'export =' to be compatible with the 'module.exports = DayPicker.default || DayPicker' syntax
// in DayPicker.js in the final NPM package.
export default DayPicker;

the import is working again.
Im using 6.2.1 with the integrated typings.

whats the correct way to import in typescript ?

regards
Tristan

@PeterKottas
Copy link

This is definitely broken/undocumented. I see the same problem.

@firsttris
Copy link
Contributor Author

firsttris commented Nov 12, 2017

Currently its possible to use import DayPicker = require('react-day-picker'); to get working typings with 6.2.1

@gpbl gpbl changed the title typescript typings no default export Typescript typings have no default export Nov 24, 2017
@gpbl
Copy link
Owner

gpbl commented Nov 24, 2017

#539 has a longer discussion which I'd like to link here.

@gpbl
Copy link
Owner

gpbl commented Nov 24, 2017

I'd just plan a major release with the right export. I'd like also to remove the common.js default exports which are the root of all the problems 😄

@gpbl
Copy link
Owner

gpbl commented Nov 25, 2017

c221e2d should fix the issues

@gpbl gpbl closed this as completed in #567 Nov 25, 2017
kimamula pushed a commit to kimamula/react-day-picker that referenced this issue Aug 17, 2022
kimamula pushed a commit to kimamula/react-day-picker that referenced this issue Aug 17, 2022
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 a pull request may close this issue.

3 participants