You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ensure added imports of types use the `type` modifier
6
+
7
+
If we'd previously add an import to `ReactNode` (e.g. in `deprecated-react-fragment`),
8
+
the codemod would import it as a value.
9
+
This breaks TypeScript projects using `verbatimModuleSyntax` as well as projects enforcing `type` imports for types.
10
+
11
+
Now we ensure new imports of types use the `type` modifier:
12
+
13
+
```diff
14
+
-import { ReactNode } from 'react'
15
+
+import { type ReactNode } from 'react'
16
+
```
17
+
18
+
This also changes how we transform the deprecated global JSX namespace.
19
+
Instead of rewriting each usage, we opt for adding another import.
20
+
The guiding principle being that we keep the changes minimal in a codemod.
21
+
22
+
Before:
23
+
24
+
```diff
25
+
import * as React from 'react'
26
+
27
+
-const element: JSX.Element
28
+
+const element: React.JSX.Element
29
+
```
30
+
31
+
After:
32
+
33
+
```diff
34
+
import * as React from 'react'
35
+
+import { type JSX } from 'react'
36
+
37
+
const element: JSX.Element
38
+
```
39
+
40
+
Note that rewriting of imports does not change the modifier.
41
+
For example, the `deprecated-vfc-codemod` rewrites `VFC` identifiers to `FC`.
42
+
If the import of `VFC` had no `type` modifier, the codemod will not add one.
43
+
44
+
This affects the following codemods:
45
+
46
+
-`deprecated-react-fragment`
47
+
-`deprecated-react-node-array`
48
+
-`scoped-jsx`
49
+
50
+
`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.
0 commit comments