Typescript runtime issues
See original GitHub issueWhen I embed this using in an ES6 JSX file, this works fine. I am using Webpack 1 and Typescript.
However, using TypeScript, I get this error (at runtime):
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in. Check the render method of `Test`.
This is my Test component:
import * as React from 'react';
import { render } from 'react-dom';
import Dropzone from 'react-dropzone';
interface TestProps {
}
export default class Test extends React.Component<TestProps, {}> {
render(){
return(
<Dropzone onDrop={() => console.log("drop")}>
<div>Try dropping some files here, or click to select files to upload.</div>
</Dropzone>
)
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:24
Top Results From Across the Web
How to make Typescript throw runtime error? - Stack Overflow
Typescript knows nothing of runtime. It's a compiler. There may be a way to get Angular (which does exist at runtime) to do...
Read more >Take control of unexpected data at runtime with TypeScript
In this article, we'll explore how to use TypeScript type definitions to get better guarantees for runtime safety.
Read more >Say Goodbye to JavaScript runtime type errors with TypeScript
Are you exhausted with JavaScript runtime type errors and you can't give up JavaScript? The perfect solution is TypeScript.
Read more >Runtime type checking · Issue #1573 · microsoft/TypeScript
I request a runtime type checking system that perhaps looks something like this: function square(x: number!) { return x * x; } Where...
Read more >Catching Runtime Errors in Compile Time with Typescript
The problem. After the lengthy intro, a little heads up - WebGL 2.0 API ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@dupski solution:
import * as Dropzone from 'react-dropzone/dist/index';This is because https://github.com/react-dropzone/react-dropzone/blob/master/package.json#L4-L5 webpack using
module, typescriptmain. In first file we haveexport default, on second -module.exports = {}Why typescript usingmain? I guess because of https://github.com/goloveychuk/ts-jest/blob/master/src/utils.ts#L208-L213 Not 100% sure.I’m facing this issue too, the problem has not been resolved and this issue should be reopened.
Currently the only way I’ve been able to use this in typescript is to not install the
@typesdefiniton, change mytsconfig.jsonto allow implicitanystatements, then import it asimport * as Dropzone from 'react-dropzone';and reference the component as<Dropzone.default>This is a lot of hassle to go through for a single component, and the workaround isn’t documented anywhere.