From 2467d3c6245bd7c3cb5e54170f01b1d41ba0ce75 Mon Sep 17 00:00:00 2001 From: Corbin Crutchley Date: Thu, 28 Nov 2024 23:36:00 -0800 Subject: [PATCH] chore!: drop support for TypeScript 5.0 and below --- docs/typescript.md | 2 +- package.json | 2 -- packages/form-core/package.json | 2 -- packages/form-core/tsconfig.legacy.json | 4 ---- packages/lit-form/package.json | 1 - packages/react-form/package.json | 2 -- packages/react-form/src/types.ts | 8 ------- packages/react-form/src/useField.tsx | 10 ++++---- packages/react-form/src/useForm.tsx | 17 +++---------- packages/react-form/tsconfig.legacy.json | 11 --------- packages/solid-form/package.json | 2 -- packages/solid-form/tsconfig.legacy.json | 11 --------- packages/valibot-form-adapter/package.json | 1 - .../valibot-form-adapter/tsconfig.legacy.json | 9 ------- packages/vue-form/package.json | 2 -- packages/vue-form/tsconfig.legacy.json | 12 ---------- packages/yup-form-adapter/package.json | 2 -- .../yup-form-adapter/tsconfig.legacy.json | 9 ------- packages/zod-form-adapter/package.json | 2 -- .../zod-form-adapter/tsconfig.legacy.json | 9 ------- pnpm-lock.yaml | 24 ++----------------- 21 files changed, 11 insertions(+), 131 deletions(-) delete mode 100644 packages/form-core/tsconfig.legacy.json delete mode 100644 packages/react-form/tsconfig.legacy.json delete mode 100644 packages/solid-form/tsconfig.legacy.json delete mode 100644 packages/valibot-form-adapter/tsconfig.legacy.json delete mode 100644 packages/vue-form/tsconfig.legacy.json delete mode 100644 packages/yup-form-adapter/tsconfig.legacy.json delete mode 100644 packages/zod-form-adapter/tsconfig.legacy.json diff --git a/docs/typescript.md b/docs/typescript.md index 143ae8c8e..19099ddc1 100644 --- a/docs/typescript.md +++ b/docs/typescript.md @@ -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. diff --git a/package.json b/package.json index eafda5b15..04501c642 100644 --- a/package.json +++ b/package.json @@ -62,8 +62,6 @@ "sherif": "^1.0.1", "solid-js": "^1.9.3", "typescript": "5.4.5", - "typescript49": "npm:typescript@4.9", - "typescript50": "npm:typescript@5.0", "typescript51": "npm:typescript@5.1", "typescript52": "npm:typescript@5.2", "typescript53": "npm:typescript@5.3", diff --git a/packages/form-core/package.json b/packages/form-core/package.json index 849c05862..9d21b3999 100644 --- a/packages/form-core/package.json +++ b/packages/form-core/package.json @@ -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", diff --git a/packages/form-core/tsconfig.legacy.json b/packages/form-core/tsconfig.legacy.json deleted file mode 100644 index 596e2cf72..000000000 --- a/packages/form-core/tsconfig.legacy.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": ["src"] -} diff --git a/packages/lit-form/package.json b/packages/lit-form/package.json index 9adab0795..dc2843bdd 100644 --- a/packages/lit-form/package.json +++ b/packages/lit-form/package.json @@ -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", diff --git a/packages/react-form/package.json b/packages/react-form/package.json index ce0232dca..82ff4b24b 100644 --- a/packages/react-form/package.json +++ b/packages/react-form/package.json @@ -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", diff --git a/packages/react-form/src/types.ts b/packages/react-form/src/types.ts index 5ee688e5e..8f39d95cb 100644 --- a/packages/react-form/src/types.ts +++ b/packages/react-form/src/types.ts @@ -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 diff --git a/packages/react-form/src/useField.tsx b/packages/react-form/src/useField.tsx index 90a97ca05..3f2fa89d4 100644 --- a/packages/react-form/src/useField.tsx +++ b/packages/react-form/src/useField.tsx @@ -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< @@ -125,7 +125,7 @@ type FieldComponentProps< TFormValidator, TData >, - ) => NodeType + ) => ReactNode } & UseFieldOptions /** @@ -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. @@ -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 diff --git a/packages/react-form/src/useForm.tsx b/packages/react-form/src/useForm.tsx index 10fd104ab..63738f43b 100644 --- a/packages/react-form/src/useForm.tsx +++ b/packages/react-form/src/useForm.tsx @@ -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` @@ -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: >>(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>) => TSelected - children: ((state: NoInfer) => NodeType) | NodeType - }) => NodeType + children: ((state: NoInfer) => ReactNode) | ReactNode + }) => ReactNode } /** diff --git a/packages/react-form/tsconfig.legacy.json b/packages/react-form/tsconfig.legacy.json deleted file mode 100644 index e7d685ff0..000000000 --- a/packages/react-form/tsconfig.legacy.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "jsx": "react", - "paths": { - "@tanstack/form-core": ["../form-core/src"] - } - }, - "include": ["src"], - "exclude": ["src/start"] -} diff --git a/packages/solid-form/package.json b/packages/solid-form/package.json index b54b0e872..890376bf6 100644 --- a/packages/solid-form/package.json +++ b/packages/solid-form/package.json @@ -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", diff --git a/packages/solid-form/tsconfig.legacy.json b/packages/solid-form/tsconfig.legacy.json deleted file mode 100644 index 35fa3e58f..000000000 --- a/packages/solid-form/tsconfig.legacy.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "jsx": "preserve", - "jsxImportSource": "solid-js", - "paths": { - "@tanstack/form-core": ["../form-core/src"] - } - }, - "include": ["src"] -} diff --git a/packages/valibot-form-adapter/package.json b/packages/valibot-form-adapter/package.json index 25186bfe7..dad7c13fc 100644 --- a/packages/valibot-form-adapter/package.json +++ b/packages/valibot-form-adapter/package.json @@ -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", diff --git a/packages/valibot-form-adapter/tsconfig.legacy.json b/packages/valibot-form-adapter/tsconfig.legacy.json deleted file mode 100644 index c9bf46d6c..000000000 --- a/packages/valibot-form-adapter/tsconfig.legacy.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "paths": { - "@tanstack/form-core": ["../form-core/src"] - } - }, - "include": ["src"] -} diff --git a/packages/vue-form/package.json b/packages/vue-form/package.json index 40184ddc0..483d726cb 100644 --- a/packages/vue-form/package.json +++ b/packages/vue-form/package.json @@ -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", diff --git a/packages/vue-form/tsconfig.legacy.json b/packages/vue-form/tsconfig.legacy.json deleted file mode 100644 index 743411d9b..000000000 --- a/packages/vue-form/tsconfig.legacy.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "jsx": "preserve", - "jsxImportSource": "vue", - "types": ["vue/jsx"], - "paths": { - "@tanstack/form-core": ["../form-core/src"] - } - }, - "include": ["src"] -} diff --git a/packages/yup-form-adapter/package.json b/packages/yup-form-adapter/package.json index 428c10044..572870b6c 100644 --- a/packages/yup-form-adapter/package.json +++ b/packages/yup-form-adapter/package.json @@ -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", diff --git a/packages/yup-form-adapter/tsconfig.legacy.json b/packages/yup-form-adapter/tsconfig.legacy.json deleted file mode 100644 index c9bf46d6c..000000000 --- a/packages/yup-form-adapter/tsconfig.legacy.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "paths": { - "@tanstack/form-core": ["../form-core/src"] - } - }, - "include": ["src"] -} diff --git a/packages/zod-form-adapter/package.json b/packages/zod-form-adapter/package.json index 3b6425537..697439294 100644 --- a/packages/zod-form-adapter/package.json +++ b/packages/zod-form-adapter/package.json @@ -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", diff --git a/packages/zod-form-adapter/tsconfig.legacy.json b/packages/zod-form-adapter/tsconfig.legacy.json deleted file mode 100644 index c9bf46d6c..000000000 --- a/packages/zod-form-adapter/tsconfig.legacy.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "paths": { - "@tanstack/form-core": ["../form-core/src"] - } - }, - "include": ["src"] -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a073a2285..2c2d53045 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -80,12 +80,6 @@ importers: typescript: specifier: 5.4.5 version: 5.4.5 - typescript49: - specifier: npm:typescript@4.9 - version: typescript@4.9.5 - typescript50: - specifier: npm:typescript@5.0 - version: typescript@5.0.4 typescript51: specifier: npm:typescript@5.1 version: typescript@5.1.6 @@ -9522,16 +9516,6 @@ packages: typescript: optional: true - typescript@4.9.5: - resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} - engines: {node: '>=4.2.0'} - hasBin: true - - typescript@5.0.4: - resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} - engines: {node: '>=12.20'} - hasBin: true - typescript@5.1.6: resolution: {integrity: sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==} engines: {node: '>=14.17'} @@ -19748,7 +19732,7 @@ snapshots: mkdirp: 1.0.4 yallist: 4.0.0 - terser-webpack-plugin@5.3.10(@swc/core@1.7.42(@swc/helpers@0.5.13))(esbuild@0.23.1)(webpack@5.94.0(@swc/core@1.7.42(@swc/helpers@0.5.13))(esbuild@0.20.1)): + terser-webpack-plugin@5.3.10(@swc/core@1.7.42(@swc/helpers@0.5.13))(esbuild@0.23.1)(webpack@5.94.0(@swc/core@1.7.42(@swc/helpers@0.5.13))(esbuild@0.23.1)): dependencies: '@jridgewell/trace-mapping': 0.3.25 jest-worker: 27.5.1 @@ -19958,10 +19942,6 @@ snapshots: - eslint - supports-color - typescript@4.9.5: {} - - typescript@5.0.4: {} - typescript@5.1.6: {} typescript@5.2.2: {} @@ -20672,7 +20652,7 @@ snapshots: neo-async: 2.6.2 schema-utils: 3.3.0 tapable: 2.2.1 - terser-webpack-plugin: 5.3.10(@swc/core@1.7.42(@swc/helpers@0.5.13))(esbuild@0.23.1)(webpack@5.94.0(@swc/core@1.7.42(@swc/helpers@0.5.13))(esbuild@0.20.1)) + terser-webpack-plugin: 5.3.10(@swc/core@1.7.42(@swc/helpers@0.5.13))(esbuild@0.23.1)(webpack@5.94.0(@swc/core@1.7.42(@swc/helpers@0.5.13))(esbuild@0.23.1)) watchpack: 2.4.2 webpack-sources: 3.2.3 transitivePeerDependencies: