Skip to content

Commit 05b9bc9

Browse files
authored
Typescript/feature highlight (#1338)
* index file .js to .tsx * migrate FeatureHighlight to typescript * demo-screen .js -> .tsx * migrate demo screen to typescript * Fixing warning * export FeatureHighlight ts component * marked part of the props as optional * removed .d.ts file * // @ts-expect-error since it hasn't been exported yet * removed redundant default props
1 parent 19f86d1 commit 05b9bc9

File tree

5 files changed

+180
-176
lines changed

5 files changed

+180
-176
lines changed

demo/src/screens/componentScreens/FeatureHighlightScreen.js renamed to demo/src/screens/componentScreens/FeatureHighlightScreen.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,22 @@ const messages = [
2323
'Here is where you can view demos of all Uilib components'
2424
];
2525

26-
class FeatureHighlightScreen extends Component {
27-
constructor(props) {
26+
interface State {
27+
currentTargetIndex: number;
28+
showFTE: boolean;
29+
}
30+
31+
class FeatureHighlightScreen extends Component<{}, State> {
32+
viewRef: any;
33+
targets: {[key: string]: any} = {};
34+
35+
constructor(props: any) {
2836
super(props);
2937

3038
this.state = {
3139
showFTE: false,
3240
currentTargetIndex: 0
3341
};
34-
35-
this.targets = {};
3642
}
3743

3844
componentDidMount() {
@@ -46,7 +52,7 @@ class FeatureHighlightScreen extends Component {
4652
this.setState({showFTE: false}, () => {
4753
if (this.viewRef) {
4854
const reactTag = findNodeHandle(this.viewRef);
49-
AccessibilityInfo.setAccessibilityFocus(reactTag);
55+
reactTag && AccessibilityInfo.setAccessibilityFocus(reactTag);
5056
}
5157
});
5258
};
@@ -55,7 +61,7 @@ class FeatureHighlightScreen extends Component {
5561
this.setState({showFTE: true});
5662
};
5763

58-
addTarget(ref, id) {
64+
addTarget(ref: any, id: string) {
5965
if (ref && !this.targets[id]) {
6066
this.targets[id] = ref;
6167
}
@@ -68,7 +74,7 @@ class FeatureHighlightScreen extends Component {
6874
this.moveToPage(newTargetIndex);
6975
};
7076

71-
moveToPage(index) {
77+
moveToPage(index: number) {
7278
if (index < _.size(this.targets)) {
7379
this.setState({currentTargetIndex: index});
7480
} else {
@@ -87,7 +93,7 @@ class FeatureHighlightScreen extends Component {
8793
};
8894
}
8995

90-
onPagePress = index => {
96+
onPagePress = (index: number) => {
9197
this.moveToPage(index);
9298
};
9399

src/components/featureHighlight/__tests__/index.spec.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import {updateConstants} from '../../../helpers/Constants';
2+
import {testable as FeatureHighlight} from '../';
23

34
describe('FeatureHighlight', () => {
4-
let FeatureHighlight;
55

66
beforeEach(() => {
77
mockScreenDimentions();
8-
FeatureHighlight = require('../index').default;
98
});
109

1110
describe('getContentPosition', () => {
1211
it('massage should be placed above element positioned below screen\'s vertical center', () => {
13-
const uut = new FeatureHighlight({});
12+
const uut = new FeatureHighlight({visible: true});
1413
uut.state = {
1514
contentTopPosition: 0
1615
};

0 commit comments

Comments
 (0)