diff --git a/packages/angular-html-parser/src/index.ts b/packages/angular-html-parser/src/index.ts index d3eff0bd2705..d3e2c91cd264 100644 --- a/packages/angular-html-parser/src/index.ts +++ b/packages/angular-html-parser/src/index.ts @@ -97,6 +97,7 @@ export function parseXml(input: string) { // For prettier export { TagContentType } from "../../compiler/src/ml_parser/tags.ts"; +export { TokenType } from "../../compiler/src/ml_parser/tokens.ts"; export { RecursiveVisitor, visitAll, @@ -111,6 +112,7 @@ export { SUPPORTED_BLOCKS as SUPPORTED_ANGULAR_BLOCKS } from "../../compiler/src // Types export type { ParseTreeResult } from "../../compiler/src/ml_parser/parser.ts"; +export type * as Tokens from "../../compiler/src/ml_parser/tokens.ts"; export type * as Ast from "../../compiler/src/ml_parser/ast.ts"; // Remove these alias in next major release diff --git a/packages/angular-html-parser/test/index_spec.ts b/packages/angular-html-parser/test/index_spec.ts index dff895cc624f..89e101cb94f9 100644 --- a/packages/angular-html-parser/test/index_spec.ts +++ b/packages/angular-html-parser/test/index_spec.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from "vitest"; -import { parse, TagContentType } from "../src/index.ts"; +import { parse, TagContentType, TokenType } from "../src/index.ts"; import { humanizeDom } from "../../compiler/test/ml_parser/ast_spec_utils.ts"; import * as ast from "../../compiler/src/ml_parser/ast.ts"; @@ -286,3 +286,15 @@ it("Edge cases", () => { [ast.Element, ":html:style", 0], ]); }); + +describe("public token API", () => { + it("should expose TokenType", () => { + const node = parse('{{ "}}" }}').rootNodes[0] as ast.Text; + expect(node).toBeInstanceOf(ast.Text); + + const token = node.tokens.find( + ({ type }) => type === TokenType.INTERPOLATION, + )!; + expect(token.parts).toEqual(["{{", ' "}}" ', "}}"]); + }); +});