Wrong importation of React in typings
See original GitHub issueAll typings starts with
import React from 'react';
Because React doesn’t have a default, in typescript it should be
import * as React from 'react';
As a result I get diagnostic errors like
Error:(21, 13) TS2605:JSX element type 'Menu' is not a constructor function for JSX elements.
Property 'setState' is missing in type 'Menu'.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Cannot use import statement outside a module [React ...
When building a web application, you may encounter the SyntaxError: Cannot use import statement outside a module error. This error might be ...
Read more >Why does require('react') cause "Import declaration ...
If I remove the import or require, however, I get a "React" undefined error. It appears that it does require some kind of...
Read more >Typescript imports are incorrectly imported from `@types/`
What steps will reproduce the problem? Use jsx in a tsx file. Get the prompt to import react. Import react; WS inserts import...
Read more >Documentation - TypeScript 3.8
TypeScript 3.8 adds a new syntax for type-only imports and exports. ... error! 'Component' only refers to a type, but is being used...
Read more >Strict Mode
import React from 'react'; function ExampleApplication() { return ( <div> ... or it may invoke them without committing at all (because of an...
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 FreeTop 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
Top GitHub Comments
See https://github.com/ant-design/ant-design#typescript
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.