Skip to content

Commit

Permalink
chore!: drop support for TypeScript 5.0 and below
Browse files Browse the repository at this point in the history
  • Loading branch information
crutchcorn committed Nov 29, 2024
1 parent 477e844 commit 2467d3c
Show file tree
Hide file tree
Showing 21 changed files with 11 additions and 131 deletions.
2 changes: 1 addition & 1 deletion docs/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ TanStack Form is written 100% in **TypeScript** with the highest quality generic
Things to keep in mind:

- `strict: true` is required in your `tsconfig.json` to get the most out of TanStack Form's types
- Types currently require using TypeScript v4.8 or greater
- Types currently require using TypeScript v5.1 or greater
- 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!).
- 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**
- The non-type-related public API of TanStack Form still follows semver very strictly.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
"sherif": "^1.0.1",
"solid-js": "^1.9.3",
"typescript": "5.4.5",
"typescript49": "npm:[email protected]",
"typescript50": "npm:[email protected]",
"typescript51": "npm:[email protected]",
"typescript52": "npm:[email protected]",
"typescript53": "npm:[email protected]",
Expand Down
2 changes: 0 additions & 2 deletions packages/form-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"clean": "rimraf ./dist && rimraf ./coverage",
"test:eslint": "eslint ./src ./tests",
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
"test:types:ts49": "node ../../node_modules/typescript49/lib/tsc.js -p tsconfig.legacy.json",
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js",
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js",
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js",
Expand Down
4 changes: 0 additions & 4 deletions packages/form-core/tsconfig.legacy.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/lit-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"clean": "rimraf ./build && rimraf ./coverage",
"test:eslint": "eslint ./src ./tests",
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js",
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js",
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js",
Expand Down
2 changes: 0 additions & 2 deletions packages/react-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"clean": "rimraf ./dist && rimraf ./coverage",
"test:eslint": "eslint ./src ./tests",
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
"test:types:ts49": "node ../../node_modules/typescript49/lib/tsc.js -p tsconfig.legacy.json",
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js -p tsconfig.legacy.json",
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js",
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js",
Expand Down
8 changes: 0 additions & 8 deletions packages/react-form/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,3 @@ export type UseFieldOptions<
> & {
mode?: 'value' | 'array'
}

/**
* The return type of React.ReactNode appears to change between React 4.9 and 5.0
*
* This means that if we replace this type with React.ReactNode, there will be
* random typings the fail between React 4.9 and 5.0. This is a hack that resolves this issue.
*/
export type NodeType = ReturnType<FunctionComponent>
10 changes: 5 additions & 5 deletions packages/react-form/src/useField.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React, { useState } from 'react'
import React, { ReactNode, useState } from 'react'
import { useStore } from '@tanstack/react-store'
import { FieldApi, functionalUpdate } from '@tanstack/form-core'
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
import type { FunctionComponent } from 'react'
import type { NodeType, UseFieldOptions } from './types'
import type { UseFieldOptions } from './types'
import type { DeepKeys, DeepValue, Validator } from '@tanstack/form-core'

interface ReactFieldApi<
Expand Down Expand Up @@ -125,7 +125,7 @@ type FieldComponentProps<
TFormValidator,
TData
>,
) => NodeType
) => ReactNode
} & UseFieldOptions<TParentData, TName, TFieldValidator, TFormValidator, TData>

/**
Expand Down Expand Up @@ -154,7 +154,7 @@ export type FieldComponent<
TData
>,
'form'
>) => NodeType
>) => ReactNode

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

return (<>{functionalUpdate(children, fieldApi as any)}</>) as never
Expand Down
17 changes: 3 additions & 14 deletions packages/react-form/src/useForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { useStore } from '@tanstack/react-store'
import React, { useState } from 'react'
import { Field, useField } from './useField'
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
import type { ReactNode } from 'react'
import type { FieldComponent, UseField } from './useField'
import type { NoInfer } from '@tanstack/react-store'
import type { FormOptions, FormState, Validator } from '@tanstack/form-core'
import type { NodeType } from './types'

/**
* Fields that are added onto the `FormAPI` from `@tanstack/form-core` and returned from `useForm`
Expand All @@ -33,20 +33,9 @@ export interface ReactFormApi<
* 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.
*/
Subscribe: <TSelected = NoInfer<FormState<TFormData>>>(props: {
/**
TypeScript versions <=5.0.4 have a bug that prevents
the type of the `TSelected` generic from being inferred
from the return type of this method.
In these versions, `TSelected` will fall back to the default
type (or `unknown` if that's not defined).
@see {@link https://github.com/TanStack/form/pull/606/files#r1506715714 | This discussion on GitHub for the details}
@see {@link https://github.com/microsoft/TypeScript/issues/52786 | The bug report in `microsoft/TypeScript`}
*/
selector?: (state: NoInfer<FormState<TFormData>>) => TSelected
children: ((state: NoInfer<TSelected>) => NodeType) | NodeType
}) => NodeType
children: ((state: NoInfer<TSelected>) => ReactNode) | ReactNode
}) => ReactNode
}

/**
Expand Down
11 changes: 0 additions & 11 deletions packages/react-form/tsconfig.legacy.json

This file was deleted.

2 changes: 0 additions & 2 deletions packages/solid-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"clean": "rimraf ./dist && rimraf ./coverage",
"test:eslint": "eslint ./src ./tests",
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
"test:types:ts49": "node ../../node_modules/typescript49/lib/tsc.js -p tsconfig.legacy.json",
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js",
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js",
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js",
Expand Down
11 changes: 0 additions & 11 deletions packages/solid-form/tsconfig.legacy.json

This file was deleted.

1 change: 0 additions & 1 deletion packages/valibot-form-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
"clean": "rimraf ./dist && rimraf ./coverage",
"test:eslint": "eslint ./src ./tests",
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js",
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js",
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js",
Expand Down
9 changes: 0 additions & 9 deletions packages/valibot-form-adapter/tsconfig.legacy.json

This file was deleted.

2 changes: 0 additions & 2 deletions packages/vue-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"clean": "rimraf ./dist && rimraf ./coverage",
"test:eslint": "eslint ./src ./tests",
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
"test:types:ts49": "node ../../node_modules/typescript49/lib/tsc.js -p tsconfig.legacy.json",
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js",
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js",
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js",
Expand Down
12 changes: 0 additions & 12 deletions packages/vue-form/tsconfig.legacy.json

This file was deleted.

2 changes: 0 additions & 2 deletions packages/yup-form-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"clean": "rimraf ./dist && rimraf ./coverage",
"test:eslint": "eslint ./src ./tests",
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
"test:types:ts49": "node ../../node_modules/typescript49/lib/tsc.js -p tsconfig.legacy.json",
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js",
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js",
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js",
Expand Down
9 changes: 0 additions & 9 deletions packages/yup-form-adapter/tsconfig.legacy.json

This file was deleted.

2 changes: 0 additions & 2 deletions packages/zod-form-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
"clean": "rimraf ./dist && rimraf ./coverage",
"test:eslint": "eslint ./src ./tests",
"test:types": "pnpm run \"/^test:types:ts[0-9]{2}$/\"",
"test:types:ts49": "node ../../node_modules/typescript49/lib/tsc.js -p tsconfig.legacy.json",
"test:types:ts50": "node ../../node_modules/typescript50/lib/tsc.js",
"test:types:ts51": "node ../../node_modules/typescript51/lib/tsc.js",
"test:types:ts52": "node ../../node_modules/typescript52/lib/tsc.js",
"test:types:ts53": "node ../../node_modules/typescript53/lib/tsc.js",
Expand Down
9 changes: 0 additions & 9 deletions packages/zod-form-adapter/tsconfig.legacy.json

This file was deleted.

24 changes: 2 additions & 22 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2467d3c

Please sign in to comment.