-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateReact18TypesFork.sh
More file actions
executable file
·726 lines (690 loc) · 25.9 KB
/
createReact18TypesFork.sh
File metadata and controls
executable file
·726 lines (690 loc) · 25.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
#!/bin/bash -ex
pushd types
for file in $(git ls-files "react/*"); do
dir=$(dirname "${file#react/}")
mkdir -p "react/v18/$dir"
cp "$file" "react/v18/$dir"
done
rm -rf react/v18/v15
rm -rf react/v18/v16
rm -rf react/v18/v17
rm react/v18/canary.d.ts
rm react/v18/experimental.d.ts
rm react/v18/test/canary.tsx
rm react/v18/test/experimental.tsx
rm react/v18/ts5.0/canary.d.ts
rm react/v18/ts5.0/experimental.d.ts
rm react/v18/ts5.0/test/canary.tsx
rm react/v18/ts5.0/test/experimental.tsx
# react-dom
for file in $(git ls-files "react-dom/*"); do
dir=$(dirname "${file#react-dom/}")
mkdir -p "react-dom/v18/$dir"
cp "$file" "react-dom/v18/$dir"
done
rm -rf react-dom/v18/v15
rm -rf react-dom/v18/v16
rm -rf react-dom/v18/v17
rm react-dom/v18/canary.d.ts
rm react-dom/v18/experimental.d.ts
rm react-dom/v18/test/canary-tests.tsx
rm react-dom/v18/test/experimental-tests.tsx
# react-is
for file in $(git ls-files "react-is/*"); do
dir=$(dirname "${file#react-is/}")
mkdir -p "react-is/v18/$dir"
cp "$file" "react-is/v18/$dir"
done
rm -rf react-is/v18/v16
rm -rf react-is/v18/v17
rm react-is/v18/canary.d.ts
rm react-is/v18/test/canary-tests.tsx
# react-test-renderer
for file in $(git ls-files "react-test-renderer/*"); do
dir=$(dirname "${file#react-test-renderer/}")
mkdir -p "react-test-renderer/v18/$dir"
cp "$file" "react-test-renderer/v18/$dir"
done
rm -rf react-test-renderer/v18/v15
rm -rf react-test-renderer/v18/v16
rm -rf react-test-renderer/v18/v17
popd
# Stage so that it's easier to amend to patch if apply fails.
git add -A
git apply --reject << 'EOF'
diff --git a/attw.json b/attw.json
index aa59897833..ac0c8cdadf 100644
--- a/attw.json
+++ b/attw.json
@@ -1439,6 +1439,7 @@
"react-date-range/v0",
"react-document-meta",
"react-dom",
+ "react-dom/v18",
"react-dynamic-number",
"react-email-editor",
"react-embed-gist",
diff --git a/types/react-dom/.npmignore b/types/react-dom/.npmignore
index 3d6bac44b6..c7676c2d49 100644
--- a/types/react-dom/.npmignore
+++ b/types/react-dom/.npmignore
@@ -6,3 +6,4 @@
/v15/
/v16/
/v17/
+/v18/
diff --git a/types/react-dom/package.json b/types/react-dom/package.json
index 9e6065022a..1ebfcb53cf 100644
--- a/types/react-dom/package.json
+++ b/types/react-dom/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/react-dom",
- "version": "18.3.9999",
+ "version": "19.0.9999",
"projects": [
"https://reactjs.org"
],
diff --git a/types/react-dom/v18/.npmignore b/types/react-dom/v18/.npmignore
index 3d6bac44b6..93e307400a 100644
--- a/types/react-dom/v18/.npmignore
+++ b/types/react-dom/v18/.npmignore
@@ -3,6 +3,3 @@
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
-/v15/
-/v16/
-/v17/
diff --git a/types/react-dom/v18/package.json b/types/react-dom/v18/package.json
index 9e6065022a..40089de1ec 100644
--- a/types/react-dom/v18/package.json
+++ b/types/react-dom/v18/package.json
@@ -16,21 +16,11 @@
"default": "./client.d.ts"
}
},
- "./canary": {
- "types": {
- "default": "./canary.d.ts"
- }
- },
"./server": {
"types": {
"default": "./server.d.ts"
}
},
- "./experimental": {
- "types": {
- "default": "./experimental.d.ts"
- }
- },
"./test-utils": {
"types": {
"default": "./test-utils/index.d.ts"
@@ -38,7 +28,7 @@
}
},
"dependencies": {
- "@types/react": "*"
+ "@types/react": "^18"
},
"devDependencies": {
"@types/react-dom": "workspace:."
diff --git a/types/react-dom/v18/test/react-dom-tests.tsx b/types/react-dom/v18/test/react-dom-tests.tsx
index c2c350b288..8f92b1347b 100644
--- a/types/react-dom/v18/test/react-dom-tests.tsx
+++ b/types/react-dom/v18/test/react-dom-tests.tsx
@@ -371,7 +371,7 @@ function createRoot() {
root.render(<div>initial render</div>);
root.render(false);
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error React 19 feature
ReactDOMClient.createRoot(document);
}
diff --git a/types/react-dom/v18/tsconfig.json b/types/react-dom/v18/tsconfig.json
index 81e804f9ce..200f7d2c8c 100644
--- a/types/react-dom/v18/tsconfig.json
+++ b/types/react-dom/v18/tsconfig.json
@@ -1,9 +1,7 @@
{
"files": [
"index.d.ts",
- "test/react-dom-tests.tsx",
- "test/experimental-tests.tsx",
- "test/canary-tests.tsx"
+ "test/react-dom-tests.tsx"
],
"compilerOptions": {
"module": "node16",
@@ -18,6 +16,11 @@
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
- "jsx": "preserve"
+ "jsx": "preserve",
+ "paths": {
+ "react-dom": [
+ "./index.d.ts"
+ ]
+ }
}
}
diff --git a/types/react-is/.npmignore b/types/react-is/.npmignore
index 56cc010f51..dea6c52641 100644
--- a/types/react-is/.npmignore
+++ b/types/react-is/.npmignore
@@ -5,3 +5,4 @@
!**/*.d.*.ts
/v16/
/v17/
+/v18/
diff --git a/types/react-is/package.json b/types/react-is/package.json
index 842f165a8a..c1a64dad57 100644
--- a/types/react-is/package.json
+++ b/types/react-is/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/react-is",
- "version": "18.3.9999",
+ "version": "19.0.9999",
"projects": [
"https://reactjs.org/"
],
diff --git a/types/react-is/v18/.npmignore b/types/react-is/v18/.npmignore
index 56cc010f51..93e307400a 100644
--- a/types/react-is/v18/.npmignore
+++ b/types/react-is/v18/.npmignore
@@ -3,5 +3,3 @@
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
-/v16/
-/v17/
diff --git a/types/react-is/v18/package.json b/types/react-is/v18/package.json
index 842f165a8a..013d4646aa 100644
--- a/types/react-is/v18/package.json
+++ b/types/react-is/v18/package.json
@@ -6,10 +6,10 @@
"https://reactjs.org/"
],
"dependencies": {
- "@types/react": "*"
+ "@types/react": "^18"
},
"devDependencies": {
- "@types/react-dom": "*",
+ "@types/react-dom": "^18",
"@types/react-is": "workspace:."
},
"owners": [
diff --git a/types/react-is/v18/tsconfig.json b/types/react-is/v18/tsconfig.json
index f2311edb57..a13e47bbf3 100644
--- a/types/react-is/v18/tsconfig.json
+++ b/types/react-is/v18/tsconfig.json
@@ -16,7 +16,6 @@
},
"files": [
"index.d.ts",
- "test/react-is-tests.tsx",
- "test/canary-tests.tsx"
+ "test/react-is-tests.tsx"
]
}
diff --git a/types/react-test-renderer/.npmignore b/types/react-test-renderer/.npmignore
index 3d6bac44b6..c7676c2d49 100644
--- a/types/react-test-renderer/.npmignore
+++ b/types/react-test-renderer/.npmignore
@@ -6,3 +6,4 @@
/v15/
/v16/
/v17/
+/v18/
diff --git a/types/react-test-renderer/package.json b/types/react-test-renderer/package.json
index 85b28077d2..786b7f3a9f 100644
--- a/types/react-test-renderer/package.json
+++ b/types/react-test-renderer/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/react-test-renderer",
- "version": "18.3.9999",
+ "version": "19.0.9999",
"projects": [
"https://facebook.github.io/react/"
],
diff --git a/types/react-test-renderer/v18/.npmignore b/types/react-test-renderer/v18/.npmignore
index 3d6bac44b6..93e307400a 100644
--- a/types/react-test-renderer/v18/.npmignore
+++ b/types/react-test-renderer/v18/.npmignore
@@ -3,6 +3,3 @@
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
-/v15/
-/v16/
-/v17/
diff --git a/types/react-test-renderer/v18/package.json b/types/react-test-renderer/v18/package.json
index 85b28077d2..be0aa415c5 100644
--- a/types/react-test-renderer/v18/package.json
+++ b/types/react-test-renderer/v18/package.json
@@ -6,7 +6,7 @@
"https://facebook.github.io/react/"
],
"dependencies": {
- "@types/react": "*"
+ "@types/react": "^18"
},
"devDependencies": {
"@types/react-test-renderer": "workspace:."
diff --git a/types/react/.npmignore b/types/react/.npmignore
index 3d6bac44b6..c7676c2d49 100644
--- a/types/react/.npmignore
+++ b/types/react/.npmignore
@@ -6,3 +6,4 @@
/v15/
/v16/
/v17/
+/v18/
diff --git a/types/react/package.json b/types/react/package.json
index 02fcc1b90a..1c7b11bdd1 100644
--- a/types/react/package.json
+++ b/types/react/package.json
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@types/react",
- "version": "18.3.9999",
+ "version": "19.0.9999",
"projects": [
"https://react.dev/"
],
diff --git a/types/react/v18/.npmignore b/types/react/v18/.npmignore
index 3d6bac44b6..93e307400a 100644
--- a/types/react/v18/.npmignore
+++ b/types/react/v18/.npmignore
@@ -3,6 +3,3 @@
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
-/v15/
-/v16/
-/v17/
diff --git a/types/react/v18/package.json b/types/react/v18/package.json
index 02fcc1b90a..da83ed1d9f 100644
--- a/types/react/v18/package.json
+++ b/types/react/v18/package.json
@@ -14,22 +14,6 @@
"default": "./index.d.ts"
}
},
- "./canary": {
- "types@<=5.0": {
- "default": "./ts5.0/canary.d.ts"
- },
- "types": {
- "default": "./canary.d.ts"
- }
- },
- "./experimental": {
- "types@<=5.0": {
- "default": "./ts5.0/experimental.d.ts"
- },
- "types": {
- "default": "./experimental.d.ts"
- }
- },
"./jsx-runtime": {
"types@<=5.0": {
"default": "./ts5.0/jsx-runtime.d.ts"
diff --git a/types/react/v18/test/elementAttributes.tsx b/types/react/v18/test/elementAttributes.tsx
index d81f0cd84c..dea2627170 100644
--- a/types/react/v18/test/elementAttributes.tsx
+++ b/types/react/v18/test/elementAttributes.tsx
@@ -133,26 +133,26 @@ const eventCallbacksTestCases = [
function formActionsTest() {
<form
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Form Actions are not supported in React 18.
action={formData => {
- // $ExpectType FormData
+ // $ExpectType any
formData;
}}
>
<input type="text" name="title" defaultValue="Hello" />
<input
type="submit"
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Form Actions are not supported in React 18.
formAction={formData => {
- // $ExpectType FormData
+ // $ExpectType any
formData;
}}
value="Save"
/>
<button
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Form Actions are not supported in React 18.
formAction={formData => {
- // $ExpectType FormData
+ // $ExpectType any
formData;
}}
>
diff --git a/types/react/v18/test/hooks.tsx b/types/react/v18/test/hooks.tsx
index d8ca70ca26..8d9f682af9 100644
--- a/types/react/v18/test/hooks.tsx
+++ b/types/react/v18/test/hooks.tsx
@@ -371,7 +371,7 @@ function useConcurrentHooks() {
// The function must be synchronous, even if it can start an asynchronous update
// it's no different from an useEffect callback in this respect
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error
startTransition(async () => {});
// Unlike Effect callbacks, though, there is no possible destructor to return
@@ -391,7 +391,8 @@ function startTransitionTest() {
transitionToPage("/");
});
- // Will not type-check in a real project but accepted in DT tests since canary.d.ts is part of compilation.
+ // callback must be synchronous
+ // @ts-expect-error
React.startTransition(async () => {});
}
diff --git a/types/react/v18/test/index.ts b/types/react/v18/test/index.ts
index b601fe5abd..1449f0a990 100644
--- a/types/react/v18/test/index.ts
+++ b/types/react/v18/test/index.ts
@@ -768,11 +768,10 @@ class RenderChildren extends React.Component<{ children?: React.ReactNode }> {
const emptyObject: React.ReactNode = {};
// @ts-expect-error
const plainObject: React.ReactNode = { dave: true };
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Promises as ReactNode is not supported in React 18.
const promise: React.ReactNode = Promise.resolve("React");
const asyncTests = async function asyncTests() {
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
const node: Awaited<React.ReactNode> = await Promise.resolve("React");
};
diff --git a/types/react/v18/test/tsx.tsx b/types/react/v18/test/tsx.tsx
index 7c259e2c02..2be4046a3b 100644
--- a/types/react/v18/test/tsx.tsx
+++ b/types/react/v18/test/tsx.tsx
@@ -561,7 +561,7 @@ imgProps.loading = "nonsense";
// @ts-expect-error
imgProps.decoding = "nonsense";
type ImgPropsWithRef = React.ComponentPropsWithRef<"img">;
-// $ExpectType ((instance: HTMLImageElement | null) => void | (() => VoidOrUndefinedOnly)) | RefObject<HTMLImageElement> | null | undefined
+// $ExpectType ((instance: HTMLImageElement | null) => void) | RefObject<HTMLImageElement> | null | undefined
type ImgPropsWithRefRef = ImgPropsWithRef["ref"];
type ImgPropsWithoutRef = React.ComponentPropsWithoutRef<"img">;
// $ExpectType false
@@ -691,7 +691,7 @@ function reactNodeTests() {
<div>{createChildren()}</div>;
// @ts-expect-error plain objects are not allowed
<div>{{ dave: true }}</div>;
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Promises as ReactNode is not supported in React 18.
<div>{Promise.resolve("React")}</div>;
}
@@ -771,17 +771,18 @@ function elementTypeTests() {
}
const ReturnPromise = () => Promise.resolve("React");
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Async components are not supported in React 18.
const FCPromise: React.FC = ReturnPromise;
class RenderPromise extends React.Component {
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Async components are not supported in React 18.
render() {
return Promise.resolve("React");
}
}
const ReturnPromiseReactNode = async ({ children }: { children?: React.ReactNode }) => children;
- const FCPromiseReactNode: React.FC = ReturnReactNode;
+ // @ts-expect-error Async components are not supported in React 18.
+ const FCPromiseReactNode: React.FC = ReturnPromiseReactNode;
class RenderPromiseReactNode extends React.Component<{ children?: React.ReactNode }> {
// @ts-expect-error class components cannot render async
async render() {
@@ -873,13 +874,13 @@ function elementTypeTests() {
<RenderReactNode />;
React.createElement(RenderReactNode);
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Async components are not supported in React 18.
<ReturnPromise />;
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Async components are not supported in React 18.
React.createElement(ReturnPromise);
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Async components are not supported in React 18.
<RenderPromise />;
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Async components are not supported in React 18.
React.createElement(RenderPromise);
// @ts-expect-error See https://github.com/microsoft/TypeScript/issues/59111
@@ -948,8 +949,7 @@ function managingRefs() {
}}
/>;
<div
- // Will not issue an error in a real project but does here since canary.d.ts is part of compilation.
- // @ts-expect-error
+ // Ref cleanup is accidentally supported in React 18.
ref={current => {
// @ts-expect-error
return function refCleanup(implicitAny) {
@@ -957,8 +957,7 @@ function managingRefs() {
}}
/>;
<div
- // Will not issue an error in a real project but does here since canary.d.ts is part of compilation.
- // @ts-expect-error
+ // Ref cleanup is accidentally supported in React 18.
ref={current => {
return function refCleanup(neverPassed: string) {
};
diff --git a/types/react/v18/ts5.0/OTHER_FILES.txt b/types/react/v18/ts5.0/OTHER_FILES.txt
index 949a9c6213..d830e68845 100644
--- a/types/react/v18/ts5.0/OTHER_FILES.txt
+++ b/types/react/v18/ts5.0/OTHER_FILES.txt
@@ -1,4 +1,2 @@
-canary.d.ts
-experimental.d.ts
jsx-dev-runtime.d.ts
jsx-runtime.d.ts
diff --git a/types/react/v18/ts5.0/test/elementAttributes.tsx b/types/react/v18/ts5.0/test/elementAttributes.tsx
index d81f0cd84c..dea2627170 100644
--- a/types/react/v18/ts5.0/test/elementAttributes.tsx
+++ b/types/react/v18/ts5.0/test/elementAttributes.tsx
@@ -133,26 +133,26 @@ const eventCallbacksTestCases = [
function formActionsTest() {
<form
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Form Actions are not supported in React 18.
action={formData => {
- // $ExpectType FormData
+ // $ExpectType any
formData;
}}
>
<input type="text" name="title" defaultValue="Hello" />
<input
type="submit"
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Form Actions are not supported in React 18.
formAction={formData => {
- // $ExpectType FormData
+ // $ExpectType any
formData;
}}
value="Save"
/>
<button
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Form Actions are not supported in React 18.
formAction={formData => {
- // $ExpectType FormData
+ // $ExpectType any
formData;
}}
>
diff --git a/types/react/v18/ts5.0/test/hooks.tsx b/types/react/v18/ts5.0/test/hooks.tsx
index d8ca70ca26..8d9f682af9 100644
--- a/types/react/v18/ts5.0/test/hooks.tsx
+++ b/types/react/v18/ts5.0/test/hooks.tsx
@@ -371,7 +371,7 @@ function useConcurrentHooks() {
// The function must be synchronous, even if it can start an asynchronous update
// it's no different from an useEffect callback in this respect
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error
startTransition(async () => {});
// Unlike Effect callbacks, though, there is no possible destructor to return
@@ -391,7 +391,8 @@ function startTransitionTest() {
transitionToPage("/");
});
- // Will not type-check in a real project but accepted in DT tests since canary.d.ts is part of compilation.
+ // callback must be synchronous
+ // @ts-expect-error
React.startTransition(async () => {});
}
diff --git a/types/react/v18/ts5.0/test/index.ts b/types/react/v18/ts5.0/test/index.ts
index b01d0c3a7f..71a73a1628 100644
--- a/types/react/v18/ts5.0/test/index.ts
+++ b/types/react/v18/ts5.0/test/index.ts
@@ -771,11 +771,10 @@ class RenderChildren extends React.Component<{ children?: React.ReactNode }> {
const emptyObject: React.ReactNode = {};
// @ts-expect-error
const plainObject: React.ReactNode = { dave: true };
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Promises as ReactNode is not supported in React 18.
const promise: React.ReactNode = Promise.resolve("React");
const asyncTests = async function asyncTests() {
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
const node: Awaited<React.ReactNode> = await Promise.resolve("React");
};
diff --git a/types/react/v18/ts5.0/test/tsx.tsx b/types/react/v18/ts5.0/test/tsx.tsx
index fdd737b1bb..2d1fb846e9 100644
--- a/types/react/v18/ts5.0/test/tsx.tsx
+++ b/types/react/v18/ts5.0/test/tsx.tsx
@@ -561,7 +561,7 @@ imgProps.loading = "nonsense";
// @ts-expect-error
imgProps.decoding = "nonsense";
type ImgPropsWithRef = React.ComponentPropsWithRef<"img">;
-// $ExpectType ((instance: HTMLImageElement | null) => void | (() => VoidOrUndefinedOnly)) | RefObject<HTMLImageElement> | null | undefined
+// $ExpectType ((instance: HTMLImageElement | null) => void) | RefObject<HTMLImageElement> | null | undefined
type ImgPropsWithRefRef = ImgPropsWithRef["ref"];
type ImgPropsWithoutRef = React.ComponentPropsWithoutRef<"img">;
// $ExpectType false
@@ -691,7 +691,7 @@ function reactNodeTests() {
<div>{createChildren()}</div>;
// @ts-expect-error plain objects are not allowed
<div>{{ dave: true }}</div>;
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Promises as ReactNode is not supported in React 18.
<div>{Promise.resolve("React")}</div>;
}
@@ -763,7 +763,7 @@ function elementTypeTests() {
// @ts-expect-error experimental release channel only
const FCPromise: React.FC = ReturnPromise;
class RenderPromise extends React.Component {
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Async components are not supported in React 18.
render() {
return Promise.resolve("React");
}
@@ -874,13 +874,13 @@ function elementTypeTests() {
<RenderReactNode />;
React.createElement(RenderReactNode);
- // @ts-expect-error Only available in experimental release channel
+ // @ts-expect-error Async components are not supported in React 18.
<ReturnPromise />;
- // @ts-expect-error Only available in experimental release channel
+ // @ts-expect-error Async components are not supported in React 18.
React.createElement(ReturnPromise);
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Async components are not supported in React 18.
<RenderPromise />;
- // Will not type-check in a real project but accepted in DT tests since experimental.d.ts is part of compilation.
+ // @ts-expect-error Async components are not supported in React 18.
React.createElement(RenderPromise);
// @ts-expect-error See https://github.com/microsoft/TypeScript/issues/59111
@@ -949,8 +949,7 @@ function managingRefs() {
}}
/>;
<div
- // Will not issue an error in a real project but does here since canary.d.ts is part of compilation.
- // @ts-expect-error
+ // Ref cleanup is accidentally supported in React 18.
ref={current => {
// @ts-expect-error
return function refCleanup(implicitAny) {
@@ -958,8 +957,7 @@ function managingRefs() {
}}
/>;
<div
- // Will not issue an error in a real project but does here since canary.d.ts is part of compilation.
- // @ts-expect-error
+ // Ref cleanup is accidentally supported in React 18.
ref={current => {
return function refCleanup(neverPassed: string) {
};
diff --git a/types/react/v18/ts5.0/tsconfig.json b/types/react/v18/ts5.0/tsconfig.json
index 61a90f2187..4a67b345fc 100644
--- a/types/react/v18/ts5.0/tsconfig.json
+++ b/types/react/v18/ts5.0/tsconfig.json
@@ -8,9 +8,7 @@
"test/cssProperties.tsx",
"test/elementAttributes.tsx",
"test/managedAttributes.tsx",
- "test/hooks.tsx",
- "test/experimental.tsx",
- "test/canary.tsx"
+ "test/hooks.tsx"
],
"compilerOptions": {
"module": "commonjs",
@@ -25,6 +23,11 @@
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
- "jsx": "preserve"
+ "jsx": "preserve",
+ "paths": {
+ "react": [
+ "./index.d.ts"
+ ]
+ }
}
}
diff --git a/types/react/v18/tsconfig.json b/types/react/v18/tsconfig.json
index 61a90f2187..4a67b345fc 100644
--- a/types/react/v18/tsconfig.json
+++ b/types/react/v18/tsconfig.json
@@ -8,9 +8,7 @@
"test/cssProperties.tsx",
"test/elementAttributes.tsx",
"test/managedAttributes.tsx",
- "test/hooks.tsx",
- "test/experimental.tsx",
- "test/canary.tsx"
+ "test/hooks.tsx"
],
"compilerOptions": {
"module": "commonjs",
@@ -25,6 +23,11 @@
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
- "jsx": "preserve"
+ "jsx": "preserve",
+ "paths": {
+ "react": [
+ "./index.d.ts"
+ ]
+ }
}
}
EOF