React-markdown: react markdown use in Typescript. TS2604: JSX element type 'Markdown' does not have any construct or call signatures

Created on 2 Aug 2018  路  3Comments  路  Source: remarkjs/react-markdown

react markdown use in Typescript.
error: TS2604: JSX element type 'Markdown' does not have any construct or call signatures

import * as Markdown from 'react-markdown';

<Markdown source={this.state.content} skipHtml={true} />
tsconfig.json:

{
  "compilerOptions": {
    "sourceMap": true,
    "module": "es6",
    "target": "es6",
    "lib": [
      "dom",
      "es7"
    ],
    "jsx": "preserve",
    "strict": true,
    "noImplicitAny": true,
    "moduleResolution": "node",
    "baseUrl": "src",
    "keyofStringsOnly": true,
    "allowSyntheticDefaultImports": true,
    "experimentalDecorators": true,
    "esModuleInterop": true,
    "typeRoots" : [
      "node_modules/@types/",
      "./typings/markdown.d.ts",
      "./typings/typings.d.ts"
    ]
  },
  "include": [
    "./src/**/*",
    "./typings/markdown.d.ts",
    "./typings/typings.d.ts"
  ],
  "exclude": [
    "node_modules",
    "dist"
  ]
}

markdown.d.ts:

declare function Markdown(props: any): any; export = Markdown;

Anyone konws how to resolve it?
Thanks very much!

Most helpful comment

No need markdown.d.ts.
tsconfig.json just add one more line is ok.

"allowSyntheticDefaultImports": true

and change import * as Markdown from 'react-markdown' to import ReactMarkdown from 'react-markdown'

All 3 comments

No need markdown.d.ts.
tsconfig.json just add one more line is ok.

"allowSyntheticDefaultImports": true

and change import * as Markdown from 'react-markdown' to import ReactMarkdown from 'react-markdown'

@Duobe's solution works (thanks!), but is there another way to solve the problem without altering tsconfig?

Not really sure how to handle this, happy to accept any pull request addressing this if it can be fixed on "my" end.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AlexLerman picture AlexLerman  路  3Comments

wqh17101 picture wqh17101  路  3Comments

joelin109 picture joelin109  路  3Comments

dekryptic picture dekryptic  路  3Comments

hiteshpatwari picture hiteshpatwari  路  3Comments