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
ReactFragmentby inlining its actual type (#326ed97a70by @eps1lon)Add codemod to replace deprecated React types related to propTypes with their counterpart from the
prop-typespackage (#3571751318by @eps1lon)Add codemod for required initial value in
useRef(#2170047404by @eps1lon)Added as
useRef-required-initial.Can be used on 18.x types but only intended for once [react] Require initial value for
useRefDefinitelyTyped/DefinitelyTyped#64920 lands.Unflag codemods for new refs (#319
80fe29cby @eps1lon)Just removing their experimental prefix since we have increased confidence in these changes after seeing their impact internally.
Add codemod to replace
LegacyRefwithRef(#347e928761by @eps1lon)Add codemod to replace deprecated
ReactNodeArrayby inlining its actual type. (#325b7f757cby @eps1lon)Patch Changes
Added missing transforms as choices to preset-19 (#341
dc10a3dby @eps1lon)Ensure added imports of types use the
typemodifier (#343f05624fby @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
verbatimModuleSyntaxas well as projects enforcingtypeimports for types.Now we ensure new imports of types use the
typemodifier: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.ElementNote that rewriting of imports does not change the modifier.
For example, the
deprecated-vfc-codemodrewritesVFCidentifiers toFC.If the import of
VFChad notypemodifier, the codemod will not add one.typemodifiers 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
a62832eby @eps1lon)Fixes multiple incorrect transform patterns that were supported by some transforms but not others.
We no longer switch to
typeimports if the original type wasn't imported with that modifier.Type parameters are now consistently preserved.
We don't add a reference to the
Reactnamespace anymore if we can just add a type import.This affects the following codemods:
deprecated-legacy-refdeprecated-react-childdeprecated-react-textdeprecated-react-typedeprecated-sfc-elementdeprecated-sfcdeprecated-stateless-componentdeprecated-void-function-componentFind and replace type usage in type parameters of call expressions (#344
8c27551by @eps1lon)Now we properly detect that e.g.
JSXis used insomeFunctionWithTypeParameters<JSX>().Affected codemods:
deprecated-react-childdeprecated-react-textscoped-jsx