refactor: use ts-expect-errpr instead of ts-ignore

This commit is contained in:
Satyajit Sahoo
2020-06-24 20:07:32 +02:00
parent 67cd44d24b
commit f00091d7ab
44 changed files with 142 additions and 153 deletions

View File

@@ -39,7 +39,7 @@ export default class BorderlessButton extends React.Component<Props> {
const { children, style, enabled, ...rest } = this.props;
return (
// @ts-ignore
// @ts-expect-error: the Animated.createAnimatedComponent types don't work properly
<AnimatedBaseButton
{...rest}
onActiveStateChange={this.handleActiveStateChange}

View File

@@ -62,7 +62,6 @@ export const getDefaultHeaderHeight = (
let headerHeight;
if (Platform.OS === 'ios') {
// @ts-ignore
if (isLandscape && !Platform.isPad) {
headerHeight = 32;
} else {
@@ -208,7 +207,7 @@ export default class HeaderSegment extends React.Component<Props, State> {
borderTopStartRadius,
borderTopWidth,
borderWidth,
// @ts-ignore: web support for shadow
// @ts-expect-error: web support for shadow
boxShadow,
elevation,
shadowColor,
@@ -250,7 +249,6 @@ export default class HeaderSegment extends React.Component<Props, State> {
borderTopStartRadius,
borderTopWidth,
borderWidth,
// @ts-ignore
boxShadow,
elevation,
shadowColor,
@@ -265,9 +263,9 @@ export default class HeaderSegment extends React.Component<Props, State> {
// So we need to filter them out
// Users can use `null` instead
for (const styleProp in safeStyles) {
// @ts-ignore
// @ts-expect-error: typescript wrongly complains that styleProp cannot be used to index safeStyles
if (safeStyles[styleProp] === undefined) {
// @ts-ignore
// @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete safeStyles[styleProp];
}

View File

@@ -35,9 +35,9 @@ export default class KeyboardManager extends React.Component<Props> {
this.clearKeyboardTimeout();
// @ts-ignore
// @ts-expect-error: currentlyFocusedInput is pretty new, so not in the type definitions
const input = TextInput.State.currentlyFocusedInput
? // @ts-ignore
? // @ts-expect-error
TextInput.State.currentlyFocusedInput()
: TextInput.State.currentlyFocusedField();

View File

@@ -16,7 +16,6 @@ try {
}
const isMaskedViewAvailable =
// @ts-ignore
UIManager.getViewManagerConfig('RNCMaskedView') != null;
export default function MaskedView({ children, ...rest }: Props) {

View File

@@ -23,7 +23,7 @@ class WebScreen extends React.Component<
return (
<View
// @ts-ignore
// @ts-expect-error: hidden exists on web, but not in React Native
hidden={!active}
style={[style, { display: active ? 'flex' : 'none' }]}
{...rest}
@@ -54,16 +54,16 @@ export const MaybeScreen = ({
...rest
}: ViewProps & {
enabled: boolean;
active: number | Animated.AnimatedInterpolation;
active: 0 | 1 | Animated.AnimatedInterpolation;
children: React.ReactNode;
}) => {
if (enabled && Platform.OS === 'web') {
// @ts-ignore
// @ts-expect-error: the Animated.createAnimatedComponent types don't work properly
return <AnimatedWebScreen active={active} {...rest} />;
}
if (enabled && Screens && Screens.screensEnabled()) {
// @ts-ignore
// @ts-expect-error: stackPresentation is incorrectly marked as required
return <Screens.Screen active={active} {...rest} />;
}

View File

@@ -145,8 +145,7 @@ function CardContainer({
);
React.useEffect(() => {
// `addListener` may not exist on web and older versions of React Native
// @ts-ignore
// @ts-expect-error: AnimatedInterpolation optionally has addListener, but the type defs don't think so
const listener = scene.progress.next?.addListener?.(
({ value }: { value: number }) => {
setPointerEvents(value <= EPSILON ? 'box-none' : 'none');
@@ -155,7 +154,7 @@ function CardContainer({
return () => {
if (listener) {
// @ts-ignore
// @ts-expect-error: AnimatedInterpolation optionally has removedListener, but the type defs don't think so
scene.progress.next?.removeListener?.(listener);
}
};

View File

@@ -243,7 +243,7 @@ export default class CardStack extends React.Component<Props, State> {
if (
oldScene &&
scene.__memo.every((it, i) => {
// @ts-ignore
// @ts-expect-error: we haven't added __memo to the annotation to prevent usage elsewhere
return oldScene.__memo[i] === it;
})
) {