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
Add codemod for required initial value in `useRef`
6
+
7
+
Added as `experimental-useRef-required-initial`.
8
+
Can be used on 18.x types but only intended for once https://github.com/DefinitelyTyped/DefinitelyTyped/pull/64920 lands.
@@ -267,7 +267,7 @@ In earlier versions of `@types/react` this codemod would change the typings.
267
267
268
268
### `experimental-refobject-defaults`
269
269
270
-
WARNING: This is an experimental codemod to intended for codebases using published types.
270
+
WARNING: This is an experimental codemod to intended for codebases using unpublished types.
271
271
Only use if you're using https://github.com/DefinitelyTyped/DefinitelyTyped/pull/64896.
272
272
273
273
`RefObject` no longer makes `current` nullable by default
@@ -307,6 +307,31 @@ If the import style doesn't match your preferences, you should set up auto-fixab
307
307
+const element: React.JSX.Element = <div />;
308
308
```
309
309
310
+
### `experimental-useRef-required-initial`
311
+
312
+
WARNING: This is an experimental codemod to intended for codebases using unpublished types.
313
+
Only use if you're using https://github.com/DefinitelyTyped/DefinitelyTyped/pull/64920.
314
+
315
+
`useRef` now always requires an initial value.
316
+
Implicit `undefined` is forbidden
317
+
318
+
```diff
319
+
import * as React from "react";
320
+
-React.useRef()
321
+
+React.useRef(undefined)
322
+
```
323
+
324
+
#### `experimental-useRef-required-initial` false-negative pattern A
325
+
326
+
Importing `useRef` via aliased named import will result in the transform being skipped.
327
+
328
+
```tsx
329
+
import { useRefasuseReactRef } from"react";
330
+
331
+
// not transformed
332
+
useReactRef<number>();
333
+
```
334
+
310
335
## Supported platforms
311
336
312
337
The following list contains officially supported runtimes.
0 commit comments