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

TypeError: react_timeout_1.default is not a function #19

Closed
ashwinsaval opened this issue Jul 4, 2017 · 4 comments
Closed

TypeError: react_timeout_1.default is not a function #19

ashwinsaval opened this issue Jul 4, 2017 · 4 comments

Comments

@ashwinsaval
Copy link

Hi,
My Jest test cases are failing with the following error:

 TypeError: react_timeout_1.default is not a function

The test case is a simple render and check if the component is loading fine. Any reason why I am facing this error while testing?

@ashwinsaval
Copy link
Author

@plougsgaard need some help here.

@ashwinsaval
Copy link
Author

ashwinsaval commented Jul 5, 2017

Okay I seem to have found the issue but it still needs a resolution, since I currently have to hack the usage of react-timeout to make it work in my tests. Surprisingly, react-timeout works fine in dev environment but not in tests. Here are my observations:

Setup

Typescript + Jest + Enzyme

Usage:

import ReactTimeout from 'react-timeout';

class MyClass {
...
}

export default ReactTimeout(MyClass)

The error

When using in dev environment, everything works fine. However, when attempting to run a simple test with my component, I get the following error:

TypeError: react_timeout_1.default is not a function

Looking at Issue microsoft/TypeScript#3019, it looks like the issue is with a missing .d.ts typescript definition file in the project.

Current Fix

We are currently working around this issue by using all imports in the following way, however it is not the final solution:

const ReactTimeout = require('react-timeout');

I would love to hear of the proper resolution of this issue and what can be done.

@plougsgaard
Copy link
Owner

@ashwinsaval

I've just been on holiday so didn't see your issue until now.

Looking at the issue you reference it seems like TypeScript needs the definition files from somewhere, and I'd be happy to add them to this project if it means greater compatibility.

If you're familiar with how to write them you could see if putting a .d.ts inside node_modules/react-timeout fixes your problem. As I don't have a reproducible test case that fails it would probably take me a while. 😄

Thanks for bringing this to attention!

@afilp
Copy link

afilp commented Jan 7, 2018

Is this just a DEV issue? Are we OK with production? I am worried whether things will break in production. Thanks!

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