callstack / callstack/react-native-paper

Missing fonts in NavigationTheme type

Đang mở
#4,751 2 bình luận 4 reaction 0 người được giao Xem trên GitHub
bug
Ngôn ngữ chính
TypeScript
Star
14.5k
Fork
2.2k
Merge trung bình
5 ngày 23 giờ
Pull request đã merge (30 ngày)
12

Mô tả

### Current behaviour
```
import { DefaultTheme, NavigationContainer } from '@react-navigation/native'
import { adaptNavigationTheme } from 'react-native-paper'
...
const { LightTheme } = adaptNavigationTheme({ reactNavigationLight: DefaultTheme })
...

...
```

Typing error in VSC:
```
Property 'fonts' is missing in type 'NavigationTheme' but required in type 'Theme'.ts(2741)
types.d.ts(22, 5): 'fonts' is declared here.
types.d.ts(313, 5): The expected type comes from property 'theme' which is declared here on type 'IntrinsicAttributes & NavigationContainerProps & { direction?: LocaleDirection | undefined; linking?: LinkingOptions<...> | undefined; fallback?: ReactNode; documentTitle?: DocumentTitleOptions | undefined; } & { ...; }'
(property) theme?: ReactNavigation.Theme | undefined
```

### Explanation
There is a discrepancy between:
`@react-navigation\native\src\types.tsx`
```
interface NativeTheme {
dark: boolean;
colors: {
...
};
fonts: {
regular: FontStyle;
medium: FontStyle;
bold: FontStyle;
heavy: FontStyle;
};
}
```
And `react-native-paper\src\types.tsx`
```
export type NavigationTheme = {
dark: boolean;
colors: {
...
};
};
```

### What have you tried so far?
Not a definitive fix, but, as a confirmation, the error disappeared with this edit in `react-native-paper\lib\typescript\types.d.ts`
```
/*psam*/type FontStyle = {
fontFamily: string;
fontWeight:
| 'normal'
| 'bold'
| '100'
| '200'
| '300'
| '400'
| '500'
| '600'
| '700'
| '800'
| '900';
};
export type NavigationTheme = {
dark: boolean;
colors: {
primary: string;
background: string;
card: string;
text: string;
border: string;
notification: string;
};
/*psam*/ fonts: {
regular: FontStyle;
medium: FontStyle;
bold: FontStyle;
heavy: FontStyle;
};
};
```

### Your Environment

| software | version
| --------------------- | -------
| @react-navigation/native | 7.1.9
| react-native | 0.79.1
| react-native-paper | 5.14.0

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

So sánh @react-navigation/native/src/types.tsx với react-native-paper/src/types.tsx, tập trung vào NativeTheme và NavigationTheme. Sử dụng ví dụ NavigationContainer được báo cáo để kiểm tra các kiểu, và xác nhận rằng lỗi missing-fonts đã biến mất sau khi các định nghĩa nguồn và các kiểu được tạo nhất quán với nhau.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
react-native, typescript
Lĩnh vực
mobile-dev
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.