Skip to content

Commit d91d665

Browse files
committed
Merge branch 'main' into peer-types
2 parents c4b764e + c1f2957 commit d91d665

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -50,24 +50,28 @@
5050
"devDependencies": {
5151
"@testing-library/dom": "^10.0.0",
5252
"@testing-library/jest-dom": "^5.11.6",
53-
"@types/react-dom": "^18.2.25",
53+
"@types/react": "^18.3.1",
5454
"chalk": "^4.1.2",
5555
"dotenv-cli": "^4.0.0",
5656
"jest-diff": "^29.7.0",
5757
"kcd-scripts": "^13.0.0",
5858
"npm-run-all": "^4.1.5",
59-
"react": "^18.3.0",
59+
"react": "^18.3.1",
6060
"react-dom": "^18.3.0",
6161
"rimraf": "^3.0.2",
6262
"typescript": "^4.1.2"
6363
},
6464
"peerDependencies": {
6565
"@testing-library/dom": "^10.0.0",
6666
"@types/react-dom": "^18.0.0",
67+
"@types/react": "^18.0.0",
6768
"react": "^18.0.0",
6869
"react-dom": "^18.0.0"
6970
},
7071
"peerDependenciesMeta": {
72+
"@types/react": {
73+
"optional": true
74+
},
7175
"@types/react-dom": {
7276
"optional": true
7377
}

types/index.d.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import {
77
prettyFormat,
88
Config as ConfigDTL,
99
} from '@testing-library/dom'
10-
import {act as reactAct} from 'react-dom/test-utils'
10+
import {act as reactDeprecatedAct} from 'react-dom/test-utils'
11+
//@ts-ignore
12+
import {act as reactAct} from 'react'
1113

1214
export * from '@testing-library/dom'
1315

@@ -245,10 +247,11 @@ export function renderHook<
245247
export function cleanup(): void
246248

247249
/**
248-
* Simply calls ReactDOMTestUtils.act(cb)
250+
* Simply calls React.act(cb)
249251
* If that's not available (older version of react) then it
250-
* simply calls the given callback immediately
252+
* simply calls the deprecated version which is ReactTestUtils.act(cb)
251253
*/
252-
export const act: typeof reactAct extends undefined
253-
? (callback: () => void) => void
254+
// IfAny<typeof reactAct, reactDeprecatedAct, reactAct> from https://stackoverflow.com/a/61626123/3406963
255+
export const act: 0 extends 1 & typeof reactAct
256+
? typeof reactDeprecatedAct
254257
: typeof reactAct

0 commit comments

Comments
 (0)