Skip to content

Commit 1701b96

Browse files
splincodefisker
andauthored
Expose TokenType (#53)
Co-authored-by: fisker <lionkay@gmail.com>
1 parent 50eb1b5 commit 1701b96

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

‎packages/angular-html-parser/src/index.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export function parseXml(input: string) {
9797

9898
// For prettier
9999
export { TagContentType } from "../../compiler/src/ml_parser/tags.ts";
100+
export { TokenType } from "../../compiler/src/ml_parser/tokens.ts";
100101
export {
101102
RecursiveVisitor,
102103
visitAll,
@@ -111,6 +112,7 @@ export { SUPPORTED_BLOCKS as SUPPORTED_ANGULAR_BLOCKS } from "../../compiler/src
111112

112113
// Types
113114
export type { ParseTreeResult } from "../../compiler/src/ml_parser/parser.ts";
115+
export type * as Tokens from "../../compiler/src/ml_parser/tokens.ts";
114116
export type * as Ast from "../../compiler/src/ml_parser/ast.ts";
115117

116118
// Remove these alias in next major release

‎packages/angular-html-parser/test/index_spec.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { describe, it, expect } from "vitest";
2-
import { parse, TagContentType } from "../src/index.ts";
2+
import { parse, TagContentType, TokenType } from "../src/index.ts";
33
import { humanizeDom } from "../../compiler/test/ml_parser/ast_spec_utils.ts";
44
import * as ast from "../../compiler/src/ml_parser/ast.ts";
55

@@ -286,3 +286,15 @@ it("Edge cases", () => {
286286
[ast.Element, ":html:style", 0],
287287
]);
288288
});
289+
290+
describe("public token API", () => {
291+
it("should expose TokenType", () => {
292+
const node = parse('{{ "}}" }}').rootNodes[0] as ast.Text;
293+
expect(node).toBeInstanceOf(ast.Text);
294+
295+
const token = node.tokens.find(
296+
({ type }) => type === TokenType.INTERPOLATION,
297+
)!;
298+
expect(token.parts).toEqual(["{{", ' "}}" ', "}}"]);
299+
});
300+
});

0 commit comments

Comments
 (0)