question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Translate class import issue with TypeScript

See original GitHub issue

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';

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
RikuVancommented, Apr 10, 2018

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

1reaction
ryandrewjohnsoncommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation - Modules - TypeScript
Modules import one another using a module loader. ... Static methods on an exported class have a similar problem - the class itself...
Read more >
How to test translation using Angular 2 Typescript #144 - GitHub
I have setup of angular2-seed project, implemented ng2-translate in it for my application. Now when i try to test translation. it gives error....
Read more >
TypeScript import/as vs import/require? - Stack Overflow
I am using TypeScript with Express/Node.js. For consuming modules, the TypeScript Handbook shows the following syntax: import express = require( ...
Read more >
Import Statements in TypeScript: Which Syntax to Use
TypeScript has multiple syntaxes for imports. When should you use which? It depends. In this blog, Jessica Kerr shares her thoughts, ...
Read more >
Translating TypeScript AWS CDK code to other languages
TypeScript supports importing either an entire namespace, or individual objects from a namespace. Each namespace includes constructs and other classes for ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found