Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3b52ad2

Browse files
erikrasCopilot
andauthored
Convert to TypeScript (#183)
* convert to TypeScript * Update src/FieldArray.test.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent a19c686 commit 3b52ad2

27 files changed

+463
-398
lines changed

‎.babelrc.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ module.exports = {
1212
}
1313
],
1414
'@babel/preset-react',
15-
'@babel/preset-flow'
15+
'@babel/preset-typescript'
1616
],
1717
plugins: [
18-
'@babel/plugin-transform-flow-strip-types',
1918
'@babel/plugin-syntax-dynamic-import',
2019
'@babel/plugin-syntax-import-meta',
2120
['@babel/plugin-proposal-class-properties', { loose }],
@@ -30,6 +29,8 @@ module.exports = {
3029
'@babel/plugin-proposal-export-namespace-from',
3130
'@babel/plugin-proposal-numeric-separator',
3231
'@babel/plugin-proposal-throw-expressions',
32+
['@babel/plugin-transform-private-methods', { loose }],
33+
['@babel/plugin-transform-private-property-in-object', { loose }],
3334
test && '@babel/plugin-transform-react-jsx-source'
3435
].filter(Boolean)
3536
}

‎.eslintignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

‎.flowconfig

Lines changed: 0 additions & 8 deletions
This file was deleted.

‎.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: CI
2+
3+
on: [push]
4+
5+
jobs:
6+
lint:
7+
name: Lint
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- name: Use Node.js ${{ matrix.node_version }}
13+
uses: actions/setup-node@v2
14+
with:
15+
node-version: "22"
16+
- name: Prepare env
17+
run: yarn install --ignore-scripts --frozen-lockfile
18+
- name: Run linter
19+
run: yarn start lint
20+
21+
prettier:
22+
name: Prettier Check
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
- name: Use Node.js ${{ matrix.node_version }}
28+
uses: actions/setup-node@v2
29+
with:
30+
node-version: "22"
31+
- name: Prepare env
32+
run: yarn install --ignore-scripts --frozen-lockfile
33+
- name: Run prettier
34+
run: yarn start prettier
35+
36+
test:
37+
name: Unit Tests
38+
runs-on: ubuntu-latest
39+
40+
steps:
41+
- uses: actions/checkout@v2
42+
- name: Use Node.js ${{ matrix.node_version }}
43+
uses: actions/setup-node@v2
44+
with:
45+
node-version: "22"
46+
- name: Prepare env
47+
run: yarn install --ignore-scripts --frozen-lockfile
48+
- name: Run unit tests
49+
run: yarn start test
50+
- name: Run code coverage
51+
uses: codecov/codecov-action@v2.1.0

‎.github/workflows/lock.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Lock Threads"
2+
3+
on:
4+
schedule:
5+
- cron: "0 * * * *"
6+
workflow_dispatch:
7+
8+
permissions:
9+
issues: write
10+
pull-requests: write
11+
12+
concurrency:
13+
group: lock
14+
15+
jobs:
16+
action:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: dessant/lock-threads@v3
20+
with:
21+
issue-inactive-days: "365"
22+
issue-lock-reason: "resolved"
23+
pr-inactive-days: "365"
24+
pr-lock-reason: "resolved"

‎eslint.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const typescriptParser = require('@typescript-eslint/parser')
2+
3+
module.exports = [
4+
{
5+
ignores: ['dist/**', 'node_modules/**', 'coverage/**']
6+
},
7+
{
8+
files: ['**/*.js', '**/*.ts', '**/*.tsx'],
9+
languageOptions: {
10+
parser: typescriptParser,
11+
ecmaVersion: 2020,
12+
sourceType: 'module',
13+
parserOptions: {
14+
ecmaFeatures: {
15+
jsx: true
16+
}
17+
}
18+
},
19+
rules: {
20+
// Minimal rules - can be expanded later
21+
}
22+
}
23+
]

‎package-scripts.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,19 @@ module.exports = {
5353
},
5454
andTest: series.nps('build', 'test.size')
5555
},
56-
copyTypes: series(
57-
npsUtils.copy('src/*.js.flow src/*.d.ts dist'),
58-
npsUtils.copy(
59-
'dist/index.js.flow dist --rename="react-final-form-arrays.cjs.js.flow"'
60-
),
61-
npsUtils.copy(
62-
'dist/index.js.flow dist --rename="react-final-form-arrays.es.js.flow"'
63-
)
64-
),
56+
copyTypes: npsUtils.copy('src/*.d.ts dist'),
6557
docs: {
6658
description: 'Generates table of contents in README',
6759
script: 'doctoc README.md'
6860
},
61+
prettier: {
62+
description: 'Runs prettier on everything',
63+
script: 'prettier --write "**/*.([jt]s*)"'
64+
},
6965
lint: {
7066
description: 'lint the entire project',
7167
script: 'eslint .'
7268
},
73-
flow: {
74-
description: 'flow check the entire project',
75-
script: 'flow check'
76-
},
7769
typescript: {
7870
description: 'typescript check the entire project',
7971
script: 'tsc'

‎package.json

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,80 +25,79 @@
2525
},
2626
"homepage": "https://github.com/final-form/react-final-form-arrays#readme",
2727
"devDependencies": {
28-
"@babel/core": "^7.19.3",
28+
"@babel/core": "^7.27.1",
2929
"@babel/plugin-proposal-class-properties": "^7.18.6",
30-
"@babel/plugin-proposal-decorators": "^7.19.3",
30+
"@babel/plugin-proposal-decorators": "^7.27.1",
3131
"@babel/plugin-proposal-export-namespace-from": "^7.18.9",
32-
"@babel/plugin-proposal-function-sent": "^7.18.6",
32+
"@babel/plugin-proposal-function-sent": "^7.27.1",
3333
"@babel/plugin-proposal-json-strings": "^7.18.6",
3434
"@babel/plugin-proposal-numeric-separator": "^7.18.6",
35-
"@babel/plugin-proposal-throw-expressions": "^7.18.6",
35+
"@babel/plugin-proposal-throw-expressions": "^7.27.1",
3636
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
3737
"@babel/plugin-syntax-import-meta": "^7.10.4",
38-
"@babel/plugin-transform-flow-strip-types": "^7.19.0",
39-
"@babel/plugin-transform-react-jsx-source": "^7.18.6",
40-
"@babel/plugin-transform-runtime": "^7.19.1",
41-
"@babel/preset-env": "^7.19.4",
42-
"@babel/preset-flow": "^7.18.6",
43-
"@babel/preset-react": "^7.18.6",
44-
"@testing-library/jest-dom": "^5.16.5",
45-
"@testing-library/react": "^11.1.0",
46-
"@types/react": "^18.0.21",
47-
"@typescript-eslint/eslint-plugin": "^5.40.1",
38+
"@babel/plugin-transform-private-methods": "^7.27.1",
39+
"@babel/plugin-transform-private-property-in-object": "^7.27.1",
40+
"@babel/plugin-transform-react-jsx-source": "^7.27.1",
41+
"@babel/plugin-transform-runtime": "^7.27.1",
42+
"@babel/preset-env": "^7.27.2",
43+
"@babel/preset-react": "^7.27.1",
44+
"@babel/preset-typescript": "^7.27.1",
45+
"@rollup/plugin-typescript": "^12.1.2",
46+
"@testing-library/dom": "^10.4.0",
47+
"@testing-library/jest-dom": "^6.6.3",
48+
"@testing-library/react": "^16.3.0",
49+
"@types/jest": "^29.5.0",
50+
"@types/react": "^19.1.5",
51+
"@typescript-eslint/eslint-plugin": "^8.32.1",
52+
"@typescript-eslint/parser": "^8.32.1",
4853
"babel-core": "^7.0.0-bridge.0",
4954
"babel-eslint": "^10.1.0",
50-
"babel-jest": "^29.2.1",
51-
"bundlesize": "^0.18.1",
55+
"babel-jest": "^29.7.0",
56+
"bundlesize": "^0.18.2",
5257
"doctoc": "^2.2.1",
53-
"eslint": "^8.25.0",
58+
"eslint": "^9.27.0",
5459
"eslint-config-react-app": "^7.0.1",
5560
"eslint-plugin-babel": "^5.3.1",
56-
"eslint-plugin-flowtype": "^8.0.3",
57-
"eslint-plugin-import": "^2.26.0",
58-
"eslint-plugin-jsx-a11y": "^6.6.1",
59-
"eslint-plugin-react": "^7.31.10",
60-
"eslint-plugin-react-hooks": "^4.6.0",
61-
"fast-check": "^3.2.0",
62-
"final-form": "^4.20.7",
63-
"final-form-arrays": "^3.0.2",
64-
"flow-bin": "^0.190.0",
65-
"glow": "^1.2.2",
66-
"husky": "^8.0.1",
67-
"jest": "^29.2.1",
68-
"jest-environment-jsdom": "^29.2.1",
69-
"jest-watch-typeahead": "^2.2.0",
70-
"lint-staged": "^10.4.2",
61+
"eslint-plugin-import": "^2.31.0",
62+
"eslint-plugin-jsx-a11y": "^6.10.2",
63+
"eslint-plugin-react": "^7.37.5",
64+
"eslint-plugin-react-hooks": "^5.2.0",
65+
"fast-check": "^4.1.1",
66+
"final-form": "^5.0.0-3",
67+
"final-form-arrays": "^4.0.0-0",
68+
"husky": "^9.1.7",
69+
"jest": "^29.7.0",
70+
"jest-environment-jsdom": "^29.7.0",
71+
"jest-watch-typeahead": "^2.2.2",
72+
"lint-staged": "^16.0.0",
7173
"nps": "^5.10.0",
7274
"nps-utils": "^1.7.0",
73-
"prettier": "^2.7.1",
74-
"prettier-eslint-cli": "^7.1.0",
75+
"prettier": "^3.5.3",
76+
"prettier-eslint-cli": "^8.0.1",
7577
"raf": "^3.4.1",
76-
"react": "^18.2.0",
77-
"react-dom": "^18.2.0",
78-
"react-final-form": "^6.5.9",
79-
"rollup": "^3.2.3",
78+
"react": "^19.1.0",
79+
"react-dom": "^19.1.0",
80+
"react-final-form": "^7.0.0-0",
81+
"rollup": "^4.41.1",
8082
"rollup-plugin-babel": "^4.4.0",
8183
"rollup-plugin-commonjs": "^10.1.0",
8284
"rollup-plugin-json": "^4.0.0",
8385
"rollup-plugin-node-resolve": "^5.2.0",
8486
"rollup-plugin-replace": "^2.2.0",
8587
"rollup-plugin-uglify": "^6.0.4",
86-
"typescript": "^4.8.4"
88+
"typescript": "^5.8.3"
8789
},
8890
"peerDependencies": {
89-
"final-form": "^4.15.0",
90-
"final-form-arrays": ">=1.0.4",
91-
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
92-
"react-final-form": "^6.2.1"
91+
"final-form": "^5.0.0-3",
92+
"final-form-arrays": "^4.0.0-0",
93+
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
94+
"react-final-form": "^7.0.0-0"
9395
},
9496
"jest": {
9597
"testEnvironment": "jsdom",
9698
"watchPlugins": [
9799
"jest-watch-typeahead/filename",
98100
"jest-watch-typeahead/testname"
99-
],
100-
"testPathIgnorePatterns": [
101-
".*\\.tsx?"
102101
]
103102
},
104103
"lint-staged": {

‎rollup.config.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import commonjs from 'rollup-plugin-commonjs'
44
import json from 'rollup-plugin-json'
55
import { uglify } from 'rollup-plugin-uglify'
66
import replace from 'rollup-plugin-replace'
7+
import typescript from '@rollup/plugin-typescript'
78

89
const minify = process.env.MINIFY
910
const format = process.env.FORMAT
@@ -36,12 +37,16 @@ const globals = {
3637
react: 'React',
3738
'final-form': 'FinalForm',
3839
'react-final-form': 'ReactFinalForm',
39-
'react-lifecycles-compat': 'ReactLifecyclesCompat'
40+
'react-lifecycles-compat': 'ReactLifecyclesCompat',
41+
'@babel/runtime/helpers/extends': '_extends',
42+
'@babel/runtime/helpers/objectWithoutPropertiesLoose':
43+
'_objectWithoutPropertiesLoose'
4044
}
4145

42-
// eslint-disable-next-line no-nested-ternary
46+
const loose = true
47+
4348
export default {
44-
input: 'src/index.js',
49+
input: 'src/index.ts',
4550
output: Object.assign(
4651
{
4752
name: 'react-final-form-arrays',
@@ -50,35 +55,43 @@ export default {
5055
},
5156
output
5257
),
53-
external: id => {
58+
external: (id) => {
5459
const isBabelRuntime = id.startsWith('@babel/runtime')
5560
const isStaticExternal = globals[id]
5661
return isBabelRuntime || isStaticExternal
5762
},
5863
plugins: [
59-
resolve({ jsnext: true, main: true }),
64+
resolve({
65+
mainFields: ['module', 'jsnext:main', 'main'],
66+
extensions: ['.js', '.jsx', '.ts', '.tsx']
67+
}),
6068
json(),
69+
typescript({
70+
tsconfig: './tsconfig.build.json',
71+
declaration: true,
72+
declarationMap: true
73+
}),
6174
commonjs({ include: 'node_modules/**' }),
6275
babel({
6376
exclude: 'node_modules/**',
77+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
6478
babelrc: false,
6579
presets: [
6680
[
6781
'@babel/preset-env',
6882
{
69-
loose: true,
83+
loose,
7084
modules: false
7185
}
7286
],
7387
'@babel/preset-react',
74-
'@babel/preset-flow'
88+
'@babel/preset-typescript'
7589
],
7690
plugins: [
77-
'@babel/plugin-transform-flow-strip-types',
7891
'@babel/plugin-transform-runtime',
7992
'@babel/plugin-syntax-dynamic-import',
8093
'@babel/plugin-syntax-import-meta',
81-
'@babel/plugin-proposal-class-properties',
94+
['@babel/plugin-proposal-class-properties',{ loose }],
8295
'@babel/plugin-proposal-json-strings',
8396
[
8497
'@babel/plugin-proposal-decorators',
@@ -89,7 +102,9 @@ export default {
89102
'@babel/plugin-proposal-function-sent',
90103
'@babel/plugin-proposal-export-namespace-from',
91104
'@babel/plugin-proposal-numeric-separator',
92-
'@babel/plugin-proposal-throw-expressions'
105+
'@babel/plugin-proposal-throw-expressions',
106+
['@babel/plugin-transform-private-methods', { loose }],
107+
['@babel/plugin-transform-private-property-in-object', { loose }]
93108
],
94109
runtimeHelpers: true
95110
}),

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /