I have this file in a react native project:
import styled, { withTheme } from 'styled-components';import { BaseText } from '../BaseText';export interface BodyProps { textAlign?: string; fontSize?: string;}export const Body = withTheme(styled(BaseText)<BodyProps>` text-align: ${props => (props.textAlign ? props.textAlign : 'center')}; font-size: ${props => (props.fontSize ? props.fontSize : '16px')};`);
I upgraded react native from 0.61.5 to 0.63.2 and started getting this lint error wherever withTheme
is being used:
TS2742: The inferred type of 'Body' cannot be named without areference to 'react-native/node_modules/@types/react'. This is likelynot portable. A type annotation is necessary.
I tried several things, but the error remains the same:
- Following this post, I added
import React from "react";
- Tried to disable tslint by adding
/* tslint:disable */
above theBody
declaration - Tried to disable tslint by adding
// tslint:disable-next-line
above theBody
declaration - Played with dependency versions. Currently I have
"@types/react": "^16.9.49"
.