Skip to content

Commit 2467d3c

Browse files
committed
chore!: drop support for TypeScript 5.0 and below
1 parent 477e844 commit 2467d3c

File tree

21 files changed

+11
-131
lines changed

21 files changed

+11
-131
lines changed

docs/typescript.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ TanStack Form is written 100% in **TypeScript** with the highest quality generic
88
Things to keep in mind:
99

1010
- `strict: true` is required in your `tsconfig.json` to get the most out of TanStack Form's types
11-
- Types currently require using TypeScript v4.8 or greater
11+
- Types currently require using TypeScript v5.1 or greater
1212
- Changes to types in this repository are considered **non-breaking** and are usually released as **patch** semver changes (otherwise every type enhancement would be a major version!).
1313
- It is **highly recommended that you lock your react-form package version to a specific patch release and upgrade with the expectation that types may be fixed or upgraded between any release**
1414
- The non-type-related public API of TanStack Form still follows semver very strictly.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@
6262
"sherif": "^1.0.1",
6363
"solid-js": "^1.9.3",
6464
"typescript": "5.4.5",
65-
"typescript49": "npm:[email protected]",
66-
"typescript50": "npm:[email protected]",
6765
"typescript51": "npm:[email protected]",
6866
"typescript52": "npm:[email protected]",
6967
"typescript53": "npm:[email protected]",

packages/form-core/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
"clean": "rimraf ./dist && rimraf ./coverage",
1919
"test:eslint": "eslint ./src ./tests",
2020
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
21-
"test:types:ts49": "node ../../node_modules/typescript49/lib/tsc.js -p tsconfig.legacy.json",
22-
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js",
2321
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
2422
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js",
2523
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js",

packages/form-core/tsconfig.legacy.json

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

packages/lit-form/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"clean": "rimraf ./build && rimraf ./coverage",
1919
"test:eslint": "eslint ./src ./tests",
2020
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
21-
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js",
2221
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
2322
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js",
2423
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js",

packages/react-form/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
"clean": "rimraf ./dist && rimraf ./coverage",
1919
"test:eslint": "eslint ./src ./tests",
2020
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
21-
"test:types:ts49": "node ../../node_modules/typescript49/lib/tsc.js -p tsconfig.legacy.json",
22-
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js -p tsconfig.legacy.json",
2321
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
2422
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js",
2523
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js",

packages/react-form/src/types.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,3 @@ export type UseFieldOptions<
2828
> & {
2929
mode?: 'value' | 'array'
3030
}
31-
32-
/**
33-
* The return type of React.ReactNode appears to change between React 4.9 and 5.0
34-
*
35-
* This means that if we replace this type with React.ReactNode, there will be
36-
* random typings the fail between React 4.9 and 5.0. This is a hack that resolves this issue.
37-
*/
38-
export type NodeType = ReturnType<FunctionComponent>

packages/react-form/src/useField.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import React, { useState } from 'react'
1+
import React, { ReactNode, useState } from 'react'
22
import { useStore } from '@tanstack/react-store'
33
import { FieldApi, functionalUpdate } from '@tanstack/form-core'
44
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
55
import type { FunctionComponent } from 'react'
6-
import type { NodeType, UseFieldOptions } from './types'
6+
import type { UseFieldOptions } from './types'
77
import type { DeepKeys, DeepValue, Validator } from '@tanstack/form-core'
88

99
interface ReactFieldApi<
@@ -125,7 +125,7 @@ type FieldComponentProps<
125125
TFormValidator,
126126
TData
127127
>,
128-
) => NodeType
128+
) => ReactNode
129129
} & UseFieldOptions<TParentData, TName, TFieldValidator, TFormValidator, TData>
130130

131131
/**
@@ -154,7 +154,7 @@ export type FieldComponent<
154154
TData
155155
>,
156156
'form'
157-
>) => NodeType
157+
>) => ReactNode
158158

159159
/**
160160
* A function component that takes field options and a render function as children and returns a React component.
@@ -180,7 +180,7 @@ export const Field = (<
180180
TFieldValidator,
181181
TFormValidator,
182182
TData
183-
>): NodeType => {
183+
>): ReactNode => {
184184
const fieldApi = useField(fieldOptions as any)
185185

186186
return (<>{functionalUpdate(children, fieldApi as any)}</>) as never

packages/react-form/src/useForm.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { useStore } from '@tanstack/react-store'
33
import React, { useState } from 'react'
44
import { Field, useField } from './useField'
55
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
6+
import type { ReactNode } from 'react'
67
import type { FieldComponent, UseField } from './useField'
78
import type { NoInfer } from '@tanstack/react-store'
89
import type { FormOptions, FormState, Validator } from '@tanstack/form-core'
9-
import type { NodeType } from './types'
1010

1111
/**
1212
* Fields that are added onto the `FormAPI` from `@tanstack/form-core` and returned from `useForm`
@@ -33,20 +33,9 @@ export interface ReactFormApi<
3333
* A `Subscribe` function that allows you to listen and react to changes in the form's state. It's especially useful when you need to execute side effects or render specific components in response to state updates.
3434
*/
3535
Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
36-
/**
37-
TypeScript versions <=5.0.4 have a bug that prevents
38-
the type of the `TSelected` generic from being inferred
39-
from the return type of this method.
40-
41-
In these versions, `TSelected` will fall back to the default
42-
type (or `unknown` if that's not defined).
43-
44-
@see {@link https://github.com/TanStack/form/pull/606/files#r1506715714 | This discussion on GitHub for the details}
45-
@see {@link https://github.com/microsoft/TypeScript/issues/52786 | The bug report in `microsoft/TypeScript`}
46-
*/
4736
selector?: (state: NoInfer<FormState<TFormData>>) => TSelected
48-
children: ((state: NoInfer<TSelected>) => NodeType) | NodeType
49-
}) => NodeType
37+
children: ((state: NoInfer<TSelected>) => ReactNode) | ReactNode
38+
}) => ReactNode
5039
}
5140

5241
/**

packages/react-form/tsconfig.legacy.json

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

0 commit comments

Comments
 (0)