Skip to content

Commit ac27b8b

Browse files
Fixed ts typings
1 parent 9a3e71e commit ac27b8b

File tree

6 files changed

+19
-14
lines changed

6 files changed

+19
-14
lines changed

index.d.ts renamed to index.d.mts

File renamed without changes.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"description": "Make your React.js rendering predictable",
77
"scripts": {
88
"test": "tsc && bun test && node ./test/all.mjs",
9-
"format": "prettier **/*.mjs **/*.ts --write",
10-
"formatCheck": "prettier **/*.mjs **/*.ts --check"
9+
"format": "prettier **/*.mjs **/*.mts --write",
10+
"formatCheck": "prettier **/*.mjs **/*.mts --check"
1111
},
1212
"type": "module",
1313
"exports": "./index.mjs",
14-
"types": "./index.d.ts",
14+
"types": "./index.d.mts",
1515
"private": false,
1616
"publishConfig": {
1717
"access": "public"

src/assertComponent.d.ts

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/assertComponent.mjs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ function assertComponent(result, expectedElement) {
88
assertComponentImpl("", result, expectedElement);
99
}
1010

11+
/**
12+
* @typedef {{
13+
* type: any;
14+
* props: { [propName: string]: any };
15+
* children?: Array<TestInstance | string>;
16+
* }} TestInstance
17+
*/
18+
1119
/**
1220
* @param { string } path
13-
* @param { import('./assertComponent').TestInstance | string } result
14-
* @param { import('./assertComponent').TestInstance | string } expectedElement
21+
* @param { TestInstance | string } result
22+
* @param { TestInstance | string } expectedElement
1523
*/
1624
function assertComponentImpl(path, result, expectedElement) {
1725
const name =
@@ -164,8 +172,8 @@ function assertAttrValue(name, resultValue, expectedValue) {
164172
}
165173

166174
/**
167-
* @param {import('./assertComponent').TestInstance} result
168-
* @returns {(import('./assertComponent').TestInstance | string)[]}
175+
* @param {TestInstance} result
176+
* @returns {(TestInstance | string)[]}
169177
*/
170178
function getComponentChildren(result) {
171179
// in case of ReactElement get children from props

test/example.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import TestRenderer from "react-test-renderer";
33
import { assertComponents, mockComponent } from "../index.mjs";
44

55
const { describe, it } = await (async () => {
6+
// @ts-ignore
7+
const module = process.isBun ? "bun:test" : "node:test";
68
// @ts-ignore
79
return process.isBun // @ts-ignore
810
? Promise.resolve({ describe: (_, fn) => fn(), it: test })
9-
: import("node:test");
11+
: import(module);
1012
})();
1113

1214
function SubComponent() {

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"noUnusedLocals": true,
2626
"noUnusedParameters": true,
2727
// use Node's module resolution algorithm, instead of the legacy TS one
28-
"moduleResolution": "node",
28+
//"moduleResolution": "node",
2929
// interop between ESM and CJS modules. Recommended by TS
3030
"esModuleInterop": true,
3131
// significant perf increase by skipping checking .d.ts files, particularly those in node_modules. Recommended by TS

0 commit comments

Comments
 (0)