Skip to content

Commit 92eedc8

Browse files
committed
fix(components): ship generated type definitions
types pointed at ./index.ts, so consumers typechecked library source under their own tsconfig and got 221 errors out of node_modules. skipLibCheck does not help — it only skips .d.ts files. Enables bob's typescript target and repoints types at lib/typescript/index.d.ts. Fixing the 22 errors that blocked declaration output caught real bugs, notably React.ReactText (removed in React 19) across 19 sites and a Calendar ref typed () => string that returns a CalendarViewMode. Also widens Button/Select/Datepicker text props to accept string|number, matching CheckBox/Toggle/Radio and what FalsyText already does at runtime, so <Button>TEXT</Button> typechecks. Type-only: the compiled bundle is byte-identical.
1 parent 7e4af6b commit 92eedc8

33 files changed

Lines changed: 105 additions & 47 deletions
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
"@ui-kitten/components": patch
3+
---
4+
5+
Ship generated type definitions instead of raw source.
6+
7+
`types` pointed at `./index.ts`, so consuming projects typechecked the library's own
8+
source under their tsconfig and saw 221 errors from `node_modules` — with no workaround,
9+
since `skipLibCheck` only skips `.d.ts` files. The package now builds `.d.ts` via
10+
react-native-builder-bob's `typescript` target and points `types` at
11+
`./lib/typescript/index.d.ts`.
12+
13+
Fixing the 22 type errors that blocked declaration output also corrected real bugs:
14+
15+
- `React.ReactText` was removed in React 19; replaced with `string | number` across 19 sites
16+
- `Calendar`'s `getViewMode()` was typed `() => string` but returns a `CalendarViewMode`
17+
- `TabView`'s view pager ref was typed as the component value rather than `ViewPagerRef`
18+
- `DatepickerProps` declared conflicting `onBlur`/`onFocus` inherited from `ViewProps`
19+
- `dateService` widened to `NativeDateService | DateService<D>` instead of `DateService<D>`
20+
21+
`Button`, `Select`, and `Datepicker` now accept `string | number` for text props, matching
22+
`CheckBox`/`Toggle`/`Radio` and the runtime behaviour of `FalsyText`. Previously the
23+
idiomatic `<Button>TEXT</Button>` did not typecheck.
24+
25+
Type-only changes — the compiled bundle is byte-identical.

src/components/devsupport/components/falsyText/falsyText.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from '../../../ui/text/text.component';
77

88
export interface FalsyTextProps extends Omit<TextProps, 'children'> {
9-
component?: RenderProp<TextProps> | React.ReactText;
9+
component?: RenderProp<TextProps> | string | number;
1010
}
1111

1212
/**

src/components/devsupport/components/measure/measure.component.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import React from 'react';
99
import {
1010
findNodeHandle,
11+
LayoutChangeEvent,
1112
Platform,
1213
UIManager,
1314
StatusBar,
@@ -18,7 +19,10 @@ export interface MeasureElementProps {
1819
force?: boolean;
1920
shouldUseTopInsets?: boolean;
2021
onMeasure: (frame: Frame) => void;
21-
children: React.ReactElement;
22+
children: React.ReactElement<{
23+
ref?: React.Ref<unknown>;
24+
onLayout?: (_event: LayoutChangeEvent) => void;
25+
}>;
2226
}
2327

2428
export type MeasuringElement = React.ReactElement;

src/components/package.json

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"description": "React Native UI components based on Eva Design System",
44
"version": "6.0.0-beta.1",
55
"main": "./lib/module/index.js",
6-
"types": "./index.ts",
6+
"types": "./lib/typescript/index.d.ts",
77
"react-native": "./index.ts",
88
"source": "./index.ts",
99
"exports": {
1010
".": {
11+
"types": "./lib/typescript/index.d.ts",
1112
"react-native": "./index.ts",
1213
"source": "./index.ts",
13-
"types": "./index.ts",
1414
"default": "./lib/module/index.js"
1515
},
1616
"./package.json": "./package.json"
@@ -58,6 +58,9 @@
5858
"react-native": ">=0.72.0",
5959
"react-native-svg": ">=13.0.0"
6060
},
61+
"devDependencies": {
62+
"typescript": "^5.3.0"
63+
},
6164
"react-native-builder-bob": {
6265
"source": ".",
6366
"output": "lib",
@@ -67,6 +70,12 @@
6770
{
6871
"esm": true
6972
}
73+
],
74+
[
75+
"typescript",
76+
{
77+
"project": "tsconfig.build.json"
78+
}
7079
]
7180
]
7281
}

src/components/theme/backdrop/backdrop.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
ViewStyle,
1818
} from 'react-native';
1919

20-
type ChildElement = React.ReactElement;
20+
type ChildElement = React.ReactElement<{ style?: StyleProp<ViewStyle> }>;
2121
type ChildrenProp = ChildElement | ChildElement[] | React.ReactNode;
2222

2323
export interface BackdropPresentingConfig {

src/components/theme/theme/withStyles.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,13 @@ export const withStyles = <P extends object, S>(Component: React.ComponentType<P
9191
}
9292
}
9393

94-
const WrappingElement = (props: WrappingProps, ref: React.Ref<WrappedElementInstance>): WrappingElementType => {
94+
const WrappingElement: React.ForwardRefRenderFunction<
95+
WrappedElementInstance,
96+
React.PropsWithoutRef<WrappingProps>
97+
> = (
98+
props,
99+
ref,
100+
): WrappingElementType => {
95101
return (
96102
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
97103
// @ts-ignore
@@ -102,7 +108,7 @@ export const withStyles = <P extends object, S>(Component: React.ComponentType<P
102108
);
103109
};
104110

105-
const ThemedComponent = React.forwardRef<WrappedElementInstance, WrappingProps>(WrappingElement);
111+
const ThemedComponent = React.forwardRef(WrappingElement);
106112

107113
ThemedComponent.displayName = Component.displayName || Component.name;
108114

src/components/ui/bottomNavigation/bottomNavigationTab.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
import { TextProps } from '../text/text.component';
3030

3131
export interface BottomNavigationTabProps extends TouchableWebProps {
32-
title?: RenderProp<TextProps> | React.ReactText;
32+
title?: RenderProp<TextProps> | string | number;
3333
icon?: RenderProp<Partial<ImageProps>>;
3434
selected?: boolean;
3535
onSelect?: (selected: boolean) => void;

src/components/ui/button/button.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {TextElement, TextProps} from '../text/text.component';
3333
type TouchableWebPropsWithoutChildren = Omit<TouchableWebProps, 'children'>;
3434

3535
export interface ButtonProps extends TouchableWebPropsWithoutChildren {
36-
children?: RenderProp<TextProps> | TextElement;
36+
children?: RenderProp<TextProps> | TextElement | string | number;
3737
/**
3838
* Function component to render to start of the text.
3939
* Expected to return an Image.

src/components/ui/calendar/baseCalendar.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ export abstract class BaseCalendarComponent<P, D = Date> extends React.Component
346346
}
347347
};
348348

349-
private renderDayIfNeeded = (item: CalendarDateInfo<D>, style: StyleType): CalendarDateContentElement => {
349+
private renderDayIfNeeded = (item: CalendarDateInfo<D>, style: StyleType): React.ReactElement => {
350350
const shouldRender: boolean = !item.bounding || this.props.boundingMonth;
351351

352352
if (shouldRender) {

src/components/ui/calendar/calendar.component.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { CalendarMonthHeader } from './components/calendarMonthHeader.component'
1515
import { CalendarPicker } from './components/picker/calendarPicker.component';
1616
import { CalendarDateContent, CalendarDateContentElement } from './components/calendarDateContent.component';
1717
import { Divider } from '../divider/divider.component';
18-
import { CalendarDateInfo, CalendarViewModes } from './type';
18+
import { CalendarDateInfo, CalendarViewMode, CalendarViewModes } from './type';
1919
import { TranslationWidth } from './i18n/type';
2020
import { DateService } from './service/date.service';
2121
import { NativeDateService } from './service/nativeDate.service';
@@ -38,7 +38,7 @@ export interface CalendarRef<D = Date> {
3838
scrollToToday: () => void;
3939
scrollToDate: (date: D) => void;
4040
getVisibleDate: () => D;
41-
getViewMode: () => string;
41+
getViewMode: () => CalendarViewMode;
4242
getPickerDate: () => D;
4343
}
4444

@@ -368,7 +368,7 @@ function CalendarComponent<D = Date>(
368368
);
369369
}, [dateService]);
370370

371-
const renderDayIfNeeded = useCallback((item: CalendarDateInfo<D>, cellStyle: StyleType): CalendarDateContentElement => {
371+
const renderDayIfNeeded = useCallback((item: CalendarDateInfo<D>, cellStyle: StyleType): React.ReactElement => {
372372
const shouldRender = !item.bounding || boundingMonth;
373373
if (shouldRender) {
374374
const renderSelector = renderDay || renderDayElement;

0 commit comments

Comments
 (0)