diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 2be0a8e5..2fd1cb7c 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -27,6 +27,7 @@ jobs: run: echo "PUBLISH_PLEASE_DISABLE_PROMPT=true" >> $GITHUB_ENV - run: npm install --ignore-scripts - run: npm run test + - run: npm run test-types-nodenext - uses: coverallsapp/github-action@v1.1.1 with: github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/package.json b/package.json index 23c4d1e5..7b2bf660 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "scripts": { "test": "c8 --reporter=lcov --reporter=text jasmine spec/*spec.js", "test-types": "tsc --noEmit spec/typings/typings-test.ts", + "test-types-nodenext": "tsc --noEmit -p spec/typings/tsconfig.nodenext.json", "unit": "jasmine", "coverage": "nyc report --reporter html --reporter text -t .nyc_output --report-dir .nyc_output/summary", "perf": "node ./benchmark/perfTest3.js", diff --git a/spec/typings/nodenext-import-test.ts b/spec/typings/nodenext-import-test.ts new file mode 100644 index 00000000..264bf762 --- /dev/null +++ b/spec/typings/nodenext-import-test.ts @@ -0,0 +1,10 @@ +/** + * Regression for GH-808: ESM declaration must use NodeNext-valid relative specifiers + * (e.g. `./pem.js` → resolves to `pem.d.ts`) so consumers with `moduleResolution: "NodeNext"` + * and `skipLibCheck: false` do not hit TS2834. + * + * Resolves the same entry as the package `import` types (`./src/fxp.d.ts`). + */ +import type { XMLParser } from "../../src/fxp.js"; + +type _Smoke = XMLParser; diff --git a/spec/typings/tsconfig.nodenext.json b/spec/typings/tsconfig.nodenext.json new file mode 100644 index 00000000..d607e547 --- /dev/null +++ b/spec/typings/tsconfig.nodenext.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "module": "NodeNext", + "moduleResolution": "NodeNext", + "strict": true, + "skipLibCheck": false, + "noEmit": true, + "types": [] + }, + "include": ["nodenext-import-test.ts"] +} diff --git a/src/fxp.d.ts b/src/fxp.d.ts index 05e38de7..84199a16 100644 --- a/src/fxp.d.ts +++ b/src/fxp.d.ts @@ -1,4 +1,4 @@ -import type { Expression, ReadonlyMatcher } from './pem'; +import type { Expression, ReadonlyMatcher } from './pem.js'; // jPath: true → string // jPath: false → ReadonlyMatcher