Skip to content

Commit 1d7cbc7

Browse files
Copilotkentcdodds
andauthored
chore: fix CI failures in Node.js 21+ and TypeScript type checking (#246)
* Initial plan * Fix CI issues: navigator assignment and typecheck error Co-authored-by: kentcdodds <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: kentcdodds <[email protected]>
1 parent d5b7792 commit 1d7cbc7

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/__tests__/setup-tests.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,12 @@ function copyProps(src, target) {
1919
// @ts-expect-error TS2322 🤷‍♂️
2020
global.window = window
2121
global.document = window.document
22-
// @ts-expect-error TS2740 🤷‍♂️
23-
global.navigator = {userAgent: 'node.js'}
22+
// Use Object.defineProperty to set navigator because in Node 21+ it's read-only
23+
Object.defineProperty(global, 'navigator', {
24+
value: {userAgent: 'node.js'},
25+
writable: true,
26+
configurable: true,
27+
})
2428
global.requestAnimationFrame = callback => setTimeout(callback, 0)
2529
global.cancelAnimationFrame = id => clearTimeout(id)
2630
copyProps(window, global)

src/remark-mdx-images.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Type declaration override for remark-mdx-images to fix type compatibility issues
2+
declare module 'remark-mdx-images' {
3+
import type {Plugin} from 'unified'
4+
const remarkMdxImages: Plugin
5+
export default remarkMdxImages
6+
}

tsconfig.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
"checkJs": true,
99
"lib": [
1010
"ES2021.String"
11-
]
12-
}
11+
],
12+
"skipLibCheck": true
13+
},
14+
"exclude": [
15+
"node_modules"
16+
]
1317
}

0 commit comments

Comments
 (0)