fix(types): resolve TypeScript errors in orientation handling

- Import OrientationLock and Orientation types from .tv.ts module
- Add explicit type annotations to orientation event handlers
- Change ScreenOrientationEnum to use Record<number, string>
- Use OrientationLock enum type instead of runtime value

This fixes ReactCodegen build failures caused by TypeScript errors.
This commit is contained in:
Uruk
2025-11-16 00:56:23 +01:00
parent d6ccd6f756
commit d89449b1bf
3 changed files with 32 additions and 20 deletions

View File

@@ -1,8 +1,10 @@
import { useEffect, useState } from "react";
import { Platform } from "react-native";
import * as ScreenOrientation from "@/packages/expo-screen-orientation";
import { OrientationLock } from "@/packages/expo-screen-orientation";
import { Orientation } from "../packages/expo-screen-orientation.tv";
import {
Orientation,
OrientationLock,
} from "../packages/expo-screen-orientation.tv";
const orientationToOrientationLock = (
orientation: Orientation,
@@ -30,13 +32,15 @@ export const useOrientation = () => {
if (Platform.isTV) return;
const orientationSubscription =
ScreenOrientation.addOrientationChangeListener((event) => {
setOrientation(
orientationToOrientationLock(event.orientationInfo.orientation),
);
});
ScreenOrientation.addOrientationChangeListener(
(event: { orientationInfo: { orientation: Orientation } }) => {
setOrientation(
orientationToOrientationLock(event.orientationInfo.orientation),
);
},
);
ScreenOrientation.getOrientationAsync().then((orientation) => {
ScreenOrientation.getOrientationAsync().then((orientation: Orientation) => {
setOrientation(orientationToOrientationLock(orientation));
});