Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.
Releases
types-react-codemod@3.1.0
Minor Changes
Add codemod to replace deprecated
ReactFragment
by inlining its actual type (#326ed97a70
by @eps1lon)Add codemod to replace deprecated React types related to propTypes with their counterpart from the
prop-types
package (#3571751318
by @eps1lon)Add codemod for required initial value in
useRef
(#2170047404
by @eps1lon)Added as
useRef-required-initial
.Can be used on 18.x types but only intended for once [react] Require initial value for
useRef
DefinitelyTyped/DefinitelyTyped#64920 lands.Unflag codemods for new refs (#319
80fe29c
by @eps1lon)Just removing their experimental prefix since we have increased confidence in these changes after seeing their impact internally.
Add codemod to replace
LegacyRef
withRef
(#347e928761
by @eps1lon)Add codemod to replace deprecated
ReactNodeArray
by inlining its actual type. (#325b7f757c
by @eps1lon)Patch Changes
Added missing transforms as choices to preset-19 (#341
dc10a3d
by @eps1lon)Ensure added imports of types use the
type
modifier (#343f05624f
by @eps1lon)If we'd previously add an import to
JSX
(e.g. inscoped-jsx
),the codemod would import it as a value.
This breaks TypeScript projects using
verbatimModuleSyntax
as well as projects enforcingtype
imports for types.Now we ensure new imports of types use the
type
modifier:This also changes how we transform the deprecated global JSX namespace.
Instead of rewriting each usage, we opt for adding another import.
The guiding principle being that we keep the changes minimal in a codemod.
Before:
After:
import * as React from 'react' +import { type JSX } from 'react' const element: JSX.Element
Note that rewriting of imports does not change the modifier.
For example, the
deprecated-vfc-codemod
rewritesVFC
identifiers toFC
.If the import of
VFC
had notype
modifier, the codemod will not add one.type
modifiers for import specifiers require [TypeScript 4.5 which has reached EOL](https://github.com/DefinitelyTyped/DefinitelyTyped#support-window in DefinitelyTyped) which is a strong signal that you should upgrade to at least TypeScript 4.6 by now.Ensure replace and rename codemods have consistent behavior (#348
a62832e
by @eps1lon)Fixes multiple incorrect transform patterns that were supported by some transforms but not others.
We no longer switch to
type
imports if the original type wasn't imported with that modifier.Type parameters are now consistently preserved.
We don't add a reference to the
React
namespace anymore if we can just add a type import.This affects the following codemods:
deprecated-legacy-ref
deprecated-react-child
deprecated-react-text
deprecated-react-type
deprecated-sfc-element
deprecated-sfc
deprecated-stateless-component
deprecated-void-function-component
Find and replace type usage in type parameters of call expressions (#344
8c27551
by @eps1lon)Now we properly detect that e.g.
JSX
is used insomeFunctionWithTypeParameters<JSX>()
.Affected codemods:
deprecated-react-child
deprecated-react-text
scoped-jsx