Skip to content

Commit 513f4ab

Browse files
Use Typescript for package sources implementation (#424)
* Install Typescript and babel plugin * Rename all source files to ts * Use TSX for Slider component * Configure TS for package compilation with Babel * Fix syntax and typechecking for mobile sources * Use native event instead of synthetic event * Add docs for tapToSeek property * Update example lockfile for packages * Convert web module into JSX file and translate into TS * Include typechecking during CI workflow * Update snapshots regarding new TS files * Update tests to use TS with JSX syntax * Update sources to new prettier parsing option * Use interface for NativeProps instead of type * Use ImageSource as a type for image instead of URI based * Use JSON for Babel config instead of JS * Rename TypeScript check to avoid copy-paste error Co-authored-by: Michał Pierzchała <[email protected]> * Cover review remarks * Keep using bubbling events for continous change * Update lockfiles after recent main changes * Fix typing for react-test-renderer by adding @types * Check for Example app typechecking and fix leftover mistakes Co-authored-by: Michał Pierzchała <[email protected]>
1 parent dd743b6 commit 513f4ab

18 files changed

+2304
-896
lines changed

.github/workflows/ReactNativeSlider-CI.yml

+9-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
key: ${{ hashFiles('./package/package.json') }}
2222

2323

24-
lint:
24+
verify-package-sources:
2525
name: Lint the sources
2626
runs-on: ubuntu-latest
2727
needs: install
@@ -39,6 +39,9 @@ jobs:
3939
- name: Run ESLint on the sources
4040
run: cd package && npx eslint src
4141

42+
- name: Run TypeScript on the sources
43+
run: cd package && npx tsc --noEmit
44+
4245

4346
test:
4447
name: Run the unit tests
@@ -59,7 +62,7 @@ jobs:
5962
run: cd package && npx jest src
6063

6164

62-
verify:
65+
verify-example-sources:
6366
name: Verify example app sources
6467
runs-on: ubuntu-latest
6568

@@ -73,11 +76,13 @@ jobs:
7376
- name: Run ESLint on the sources
7477
run: cd example && npx eslint .
7578

79+
- name: Run TypeScript on the sources
80+
run: cd example && npx tsc --noEmit
7681

7782
build-android-app:
7883
name: Build example app Android
7984
runs-on: ubuntu-latest
80-
needs: [verify]
85+
needs: [verify-example-sources]
8186

8287
steps:
8388
- uses: actions/checkout@v3
@@ -97,7 +102,7 @@ jobs:
97102
build-iOS-app:
98103
name: Build example app iOS
99104
runs-on: macos-latest
100-
needs: [verify]
105+
needs: [verify-example-sources]
101106
steps:
102107
- uses: actions/checkout@v3
103108

example/SliderExample.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export const examples = [
174174
{
175175
title: 'Vertical slider',
176176
platform: 'windows',
177-
render(): Element<any> {
177+
render() {
178178
return <SliderExample value={0.6} vertical />;
179179
},
180180
},

example/package-lock.json

+8-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// prettier-ignore
22
{
3+
"include": ["./SliderExample.tsx", "./App.tsx", "./index.tsx"],
34
"extends": "@tsconfig/react-native/tsconfig.json", /* Recommended React Native TSConfig base */
45
"compilerOptions": {
56
/* Visit https://aka.ms/tsconfig.json to read more about this file */

package/babel.config.js

-3
This file was deleted.

package/babel.config.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["@babel/preset-typescript", "module:metro-react-native-babel-preset"]
3+
}

0 commit comments

Comments
 (0)