From 4f9455d984fbd30643e02120e7e5b301e6ae39fd Mon Sep 17 00:00:00 2001 From: eyelidlessness Date: Wed, 15 Mar 2023 15:53:16 -0700 Subject: [PATCH] Fix: DOM types Fixes: - Node: A couple of type errors which were mistakenly introduced when excluding global DOM types - Web: Node types were mistakenly being included by `tsconfig.web.json`, as well as `src/dom/index.ts` (which wasn't actually in use, it was a naive first attempt at setting up aliasing for each target's DOM implementation) --- src/dom/index.ts | 10 ---------- src/dom/node/Document.ts | 2 ++ src/dom/node/XPathResult.ts | 2 +- tsconfig.web.json | 1 + 4 files changed, 4 insertions(+), 11 deletions(-) delete mode 100644 src/dom/index.ts diff --git a/src/dom/index.ts b/src/dom/index.ts deleted file mode 100644 index 0667b18..0000000 --- a/src/dom/index.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Note: we **intentionally** neither import nor export anything from - * `/src/dom/web/*`. This is because merely referencing them will cause the - * entire project to incorrectly have global `dom` and `dom.iterble` lib types. - * Instead, we have a separate TypeScript config which aliases the web types to - * ensure they're compatible. - */ - -export type { DOM } from './abstract'; -export * from './node'; diff --git a/src/dom/node/Document.ts b/src/dom/node/Document.ts index 912798e..a0c456e 100644 --- a/src/dom/node/Document.ts +++ b/src/dom/node/Document.ts @@ -4,6 +4,8 @@ import type { DOM } from '../abstract'; import { NodeTypes } from '../shared'; import { XPathResult } from './XPathResult'; +type Node = typeof libxmljs.Node; + const { Document, Element } = libxmljs; /** @package */ diff --git a/src/dom/node/XPathResult.ts b/src/dom/node/XPathResult.ts index 35a5934..a7a313e 100644 --- a/src/dom/node/XPathResult.ts +++ b/src/dom/node/XPathResult.ts @@ -14,7 +14,7 @@ export class XPathResult implements DOM.XPathResult { return this.results.length; } - constructor(private results: Node[]) {} + constructor(private results: DOM.Node[]) {} snapshotItem(index: number) { return this.results[index]; diff --git a/tsconfig.web.json b/tsconfig.web.json index 97e4186..3ad9d38 100644 --- a/tsconfig.web.json +++ b/tsconfig.web.json @@ -13,6 +13,7 @@ "exclude": [ "dist", "node_modules", + "src/dom/node/*", "./typings/env/node.d.ts", "./typings/env/test.d.ts" ],