Skip to content

Commit

Permalink
fix: export tree adapter types as namespace to support TS4.x (#1313)
Browse files Browse the repository at this point in the history
Exports the tree adapter types as a namespace, individually. This
reintroduces typescript 4.x support, which we accidentally broke in a
non-breaking release.
  • Loading branch information
43081j authored Oct 28, 2024
1 parent a05d741 commit c4a4eb7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion packages/parse5/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,21 @@ import type { DefaultTreeAdapterMap } from './tree-adapters/default.js';
import type { TreeAdapterTypeMap } from './tree-adapters/interface.js';

export { type DefaultTreeAdapterMap, defaultTreeAdapter } from './tree-adapters/default.js';
export type * as DefaultTreeAdapterTypes from './tree-adapters/default.js';
import type * as DefaultTreeAdapter from './tree-adapters/default.js';
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace DefaultTreeAdapterTypes {
export type Document = DefaultTreeAdapter.Document;
export type DocumentFragment = DefaultTreeAdapter.DocumentFragment;
export type Element = DefaultTreeAdapter.Element;
export type CommentNode = DefaultTreeAdapter.CommentNode;
export type TextNode = DefaultTreeAdapter.TextNode;
export type Template = DefaultTreeAdapter.Template;
export type DocumentType = DefaultTreeAdapter.DocumentType;
export type ParentNode = DefaultTreeAdapter.ParentNode;
export type ChildNode = DefaultTreeAdapter.ChildNode;
export type Node = DefaultTreeAdapter.Node;
export type DefaultTreeAdapterMap = DefaultTreeAdapter.DefaultTreeAdapterMap;
}
export type { TreeAdapter, TreeAdapterTypeMap } from './tree-adapters/interface.js';
export { type ParserOptions, /** @internal */ Parser } from './parser/index.js';
export { serialize, serializeOuter, type SerializerOptions } from './serializer/index.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/parse5/lib/parser/open-element-stack.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as assert from 'node:assert';
import { TAG_ID as $, TAG_NAMES as TN, NS } from '../common/html.js';
import { OpenElementStack } from './open-element-stack.js';
import type { TreeAdapterTypeMap } from '../tree-adapters/interface';
import type { TreeAdapterTypeMap } from '../tree-adapters/interface.js';
import { generateTestsForEachTreeAdapter } from 'parse5-test-utils/utils/common.js';

function ignore(): void {
Expand Down

0 comments on commit c4a4eb7

Please sign in to comment.