`tsc` fails on react-select
See original GitHub issueNo matter if I use v4 or v5 beta, when I’m trying to build my project, I get the following errors:
$ npx tsc
node_modules/react-select/src/components/Menu.tsx:10:30 - error TS7016: Could not find a declaration file for module 'react-dom'. '/Users/mvoloskov/repos/feedsauce-frontend/node_modules/react-dom/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/react-dom` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-dom';`
10 import { createPortal } from 'react-dom';
~~~~~~~~~~~
node_modules/react-select/src/components/Menu.tsx:297:3 - error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Component<MenuPlacerProps<Option, IsMulti, Group>, MenuState, any>'.
297 state: MenuState = {
~~~~~
node_modules/react-select/src/components/Menu.tsx:301:10 - error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Component<MenuPlacerProps<Option, IsMulti, Group>, MenuState, any>'.
301 static contextType = PortalPlacementContext;
~~~~~~~~~~~
node_modules/react-select/src/components/Menu.tsx:302:3 - error TS2612: Property 'context' will overwrite the base property in 'Component<MenuPlacerProps<Option, IsMulti, Group>, MenuState, any>'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration.
302 context!: ContextType<typeof PortalPlacementContext>;
~~~~~~~
node_modules/react-select/src/components/Menu.tsx:302:3 - error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Component<MenuPlacerProps<Option, IsMulti, Group>, MenuState, any>'.
302 context!: ContextType<typeof PortalPlacementContext>;
~~~~~~~
node_modules/react-select/src/components/Menu.tsx:341:3 - error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Component<MenuPlacerProps<Option, IsMulti, Group>, MenuState, any>'.
341 render() {
~~~~~~
node_modules/react-select/src/components/Menu.tsx:566:3 - error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Component<MenuPortalProps<Option, IsMulti, Group>, MenuPortalState, any>'.
566 state: MenuPortalState = { placement: null };
~~~~~
node_modules/react-select/src/components/Menu.tsx:577:3 - error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Component<MenuPortalProps<Option, IsMulti, Group>, MenuPortalState, any>'.
577 render() {
~~~~~~
node_modules/react-select/src/Select.tsx:574:3 - error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Component<Props<Option, IsMulti, Group>, State<Option, IsMulti, Group>, any>'.
574 state: State<Option, IsMulti, Group> = {
~~~~~
node_modules/react-select/src/Select.tsx:705:3 - error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Component<Props<Option, IsMulti, Group>, State<Option, IsMulti, Group>, any>'.
705 componentDidMount() {
~~~~~~~~~~~~~~~~~
node_modules/react-select/src/Select.tsx:718:3 - error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Component<Props<Option, IsMulti, Group>, State<Option, IsMulti, Group>, any>'.
718 componentDidUpdate(prevProps: Props<Option, IsMulti, Group>) {
~~~~~~~~~~~~~~~~~~
node_modules/react-select/src/Select.tsx:747:3 - error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Component<Props<Option, IsMulti, Group>, State<Option, IsMulti, Group>, any>'.
747 componentWillUnmount() {
~~~~~~~~~~~~~~~~~~~~
node_modules/react-select/src/Select.tsx:1152:57 - error TS6133: 'event' is declared but its value is never read.
1152 onMenuMouseMove: MouseEventHandler<HTMLDivElement> = (event) => {
~~~~~
node_modules/react-select/src/Select.tsx:1849:49 - error TS7030: Not all code paths return a value.
1849 menuUI = this.getCategorizedOptions().map((item) => {
~~~~~~~~~~~
node_modules/react-select/src/Select.tsx:2013:3 - error TS4114: This member must have an 'override' modifier because it overrides a member in the base class 'Component<Props<Option, IsMulti, Group>, State<Option, IsMulti, Group>, any>'.
2013 render() {
~~~~~~
Found 15 errors.
What shouls I do?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
Typescript build error #3665 - JedWatson/react-select - GitHub
I've encountered a similar issue when TS tooling auto-imported Select from react-select/src/Select , it can be fixed by importing from react- ...
Read more >React package -> tsc 2.2.2 error TS1005, TS1128, TS1109 ...
The error was in tsconfig.json . Added: "lib": [ "dom" ], "jsx": "react",. Complete files: tsconfig.json:
Read more >Documentation - tsc CLI Options - TypeScript
Flag Type Default
‑‑allowJs boolean false
‑‑allowUmdGlobalAccess boolean false
‑‑allowUnreachableCode boolean
Read more >Static Type Checking - React
It lets you annotate the variables, functions, and React components with a special type syntax ... Installing TypeScript gives us access to the...
Read more >TypeScript Compiling with Visual Studio Code
If you selected tsc: watch, the TypeScript compiler watches for changes to your TypeScript files and runs the transpiler on each change.
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
Thanks, it worked.
To those who will encounter this issue in the future — just never import anything from ‘react-select/src’.
I believe that should fix it. I’ll also make a PR to export
ThemeConfig
at the top-level so that you don’t have to import it fromdist
.