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

Translate class import issue with TypeScript #68

Closed
gnyekhelyi opened this issue Apr 10, 2018 · 9 comments
Closed

Translate class import issue with TypeScript #68

gnyekhelyi opened this issue Apr 10, 2018 · 9 comments

Comments

@gnyekhelyi
Copy link

import { Translate } from 'react-localize-redux';
Throws:
Module '".../node_modules/react-localize-redux/lib/index"' has no exported member 'Translate'.

import Translate from 'react-localize-redux';
Throws:
"export 'default' (imported as 'Translate') was not found in 'react-localize-redux'

import * as Translate from 'react-localize-redux';
Throws:
JSX element type 'Translate' does not have any construct or call signatures.

Modifying
export default class Translate extends ReactComponent<TranslateProps> {}
to
export class Translate extends ReactComponent<TranslateProps> {}
in index.ts.d fixes the issue for me, I can use the following syntax to import Translate without any errors:
import { Translate } from 'react-localize-redux';

@ryandrewjohnson
Copy link
Owner

@gnyekhelyi what version of react-localize-redux you using? Also are you using Typescript, and if so which version?

@gnyekhelyi
Copy link
Author

I'm using react-localize-redux 2.17.3 and typescript 2.7.2.

package.json.txt

@ryandrewjohnson
Copy link
Owner

ryandrewjohnson commented Apr 10, 2018

K problem is the fix I made to make in 2.17.3 didn't make it in. Currently the TS definition incorrectly exports Translate as default.

// current index.d.ts has this...
export default class Translate extends ReactComponent<TranslateProps> {}

// should be this...
export class Translate extends ReactComponent<TranslateProps> {}

I have the fix, but I won't be able to publish until this evening.

In the meantime if you want to manually update your index.d.ts file this should fix the issue until I can publish a new package this evening.

@gnyekhelyi I was able to publish the fix with the proper export in v2.17.4. Please let me know if this solves the issue you're having.

@gnyekhelyi
Copy link
Author

Ok, thank you!

@ryandrewjohnson
Copy link
Owner

@gnyekhelyi let me know if you have any interest in helping with #69.

@RikuVan
Copy link

RikuVan commented Apr 10, 2018

Thanks for the quick response. I am using your lib in a new project with TypeScript and would like to see it keep working. I might be able to lend a hand with typings, if nothing else at then at least two smoke test new typings. I am pretty new to Typescript though.

@ryandrewjohnson
Copy link
Owner

ryandrewjohnson commented Apr 10, 2018

@RikuVan any help would be appreciated! Also did that latest release v2.17.4 fix the issue you were having?

@RikuVan
Copy link

RikuVan commented Apr 10, 2018

yep I had the same issue. Seems ok, although I am still refactoring now to update with the new api.

@ryandrewjohnson
Copy link
Owner

Closing this issue based on RikuVan’s feedback.

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

No branches or pull requests

3 participants