Skip to content

Commit 2112a7c

Browse files
committed
Rename Node.type to Node.kind
1 parent 5e6261b commit 2112a7c

File tree

3 files changed

+36
-34
lines changed

3 files changed

+36
-34
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,6 @@ export {
9797
ParseSourceFile,
9898
} from "../../compiler/src/parse_util.js";
9999
export { getHtmlTagDefinition } from "../../compiler/src/ml_parser/html_tags.js";
100+
101+
// Types
102+
export type * as Ast from "../../compiler/src/ml_parser/ast.js";

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

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ describe("AST format", () => {
6868
const input = `<!DOCTYPE html> <el attr></el>txt<!-- --><![CDATA[foo]]>`;
6969
const ast = parse(input);
7070
expect(ast.rootNodes).toEqual([
71-
expect.objectContaining({ type: "docType" }),
72-
expect.objectContaining({ type: "text" }),
71+
expect.objectContaining({ kind: "docType" }),
72+
expect.objectContaining({ kind: "text" }),
7373
expect.objectContaining({
74-
type: "element",
75-
attrs: [expect.objectContaining({ type: "attribute" })],
74+
kind: "element",
75+
attrs: [expect.objectContaining({ kind: "attribute" })],
7676
}),
77-
expect.objectContaining({ type: "text" }),
78-
expect.objectContaining({ type: "comment" }),
79-
expect.objectContaining({ type: "cdata" }),
77+
expect.objectContaining({ kind: "text" }),
78+
expect.objectContaining({ kind: "comment" }),
79+
expect.objectContaining({ kind: "cdata" }),
8080
]);
8181
});
8282

@@ -86,23 +86,23 @@ describe("AST format", () => {
8686
expect(ast.rootNodes).toEqual([
8787
expect.objectContaining({
8888
name: "if",
89-
type: "block",
89+
kind: "block",
9090
parameters: [
9191
expect.objectContaining({
92-
type: "blockParameter",
92+
kind: "blockParameter",
9393
expression: "user.isHuman",
9494
}),
9595
],
9696
children: [
97-
expect.objectContaining({ type: "text", value: " " }),
97+
expect.objectContaining({ kind: "text", value: " " }),
9898
expect.objectContaining({
99-
type: "element",
99+
kind: "element",
100100
name: "p",
101101
children: [
102-
expect.objectContaining({ type: "text", value: "Hello human" }),
102+
expect.objectContaining({ kind: "text", value: "Hello human" }),
103103
],
104104
}),
105-
expect.objectContaining({ type: "text", value: " " }),
105+
expect.objectContaining({ kind: "text", value: " " }),
106106
],
107107
}),
108108
]);
@@ -114,7 +114,7 @@ describe("AST format", () => {
114114
expect(ast.rootNodes).toEqual([
115115
expect.objectContaining({
116116
name: "foo",
117-
type: "letDeclaration",
117+
kind: "letDeclaration",
118118
value: "'bar'",
119119
}),
120120
]);
@@ -129,11 +129,11 @@ describe("AST format", () => {
129129
expect(ast.rootNodes).toEqual([
130130
expect.objectContaining({
131131
name: "div",
132-
type: "element",
132+
kind: "element",
133133
directives: [
134134
expect.objectContaining({
135135
name: "Dir",
136-
type: "directive",
136+
kind: "directive",
137137
}),
138138
],
139139
}),
@@ -149,7 +149,7 @@ describe("AST format", () => {
149149
expect.objectContaining({
150150
fullName: "MyComp",
151151
componentName: "MyComp",
152-
type: "component",
152+
kind: "component",
153153
}),
154154
]);
155155
}
@@ -160,7 +160,7 @@ describe("AST format", () => {
160160
expect.objectContaining({
161161
fullName: "MyComp",
162162
componentName: "MyComp",
163-
type: "component",
163+
kind: "component",
164164
}),
165165
]);
166166
}
@@ -173,7 +173,7 @@ describe("AST format", () => {
173173
expect.objectContaining({
174174
fullName: "MyComp:button",
175175
componentName: "MyComp",
176-
type: "component",
176+
kind: "component",
177177
}),
178178
]);
179179
}
@@ -186,7 +186,7 @@ describe("AST format", () => {
186186
expect.objectContaining({
187187
fullName: "MyComp:svg:title",
188188
componentName: "MyComp",
189-
type: "component",
189+
kind: "component",
190190
}),
191191
]);
192192
}

packages/compiler/src/ml_parser/ast.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class Text extends NodeWithI18n {
5151
override visit(visitor: Visitor, context: any): any {
5252
return visitor.visitText(this, context);
5353
}
54-
readonly type = 'text';
54+
readonly kind = 'text';
5555
}
5656

5757
export class CDATA extends NodeWithI18n {
@@ -66,7 +66,7 @@ export class CDATA extends NodeWithI18n {
6666
override visit(visitor: Visitor, context: any): any {
6767
return visitor.visitCdata(this, context);
6868
}
69-
readonly type = 'cdata';
69+
readonly kind = 'cdata';
7070
}
7171

7272
export class Expansion extends NodeWithI18n {
@@ -83,8 +83,7 @@ export class Expansion extends NodeWithI18n {
8383
override visit(visitor: Visitor, context: any): any {
8484
return visitor.visitExpansion(this, context);
8585
}
86-
87-
readonly type = 'expansion';
86+
readonly kind = 'expansion';
8887
}
8988

9089
export class ExpansionCase implements BaseNode {
@@ -100,7 +99,7 @@ export class ExpansionCase implements BaseNode {
10099
return visitor.visitExpansionCase(this, context);
101100
}
102101

103-
readonly type = 'expansionCase';
102+
readonly kind = 'expansionCase';
104103
}
105104

106105
export class Attribute extends NodeWithI18n {
@@ -118,7 +117,7 @@ export class Attribute extends NodeWithI18n {
118117
override visit(visitor: Visitor, context: any): any {
119118
return visitor.visitAttribute(this, context);
120119
}
121-
readonly type = 'attribute';
120+
readonly kind = 'attribute';
122121
// angular-html-parser: backwards compatibility for Prettier
123122
get nameSpan() {
124123
return this.keySpan;
@@ -144,7 +143,7 @@ export class Element extends NodeWithI18n {
144143
override visit(visitor: Visitor, context: any): any {
145144
return visitor.visitElement(this, context);
146145
}
147-
readonly type = 'element';
146+
readonly kind = 'element';
148147
}
149148

150149
export class Comment implements BaseNode {
@@ -155,15 +154,15 @@ export class Comment implements BaseNode {
155154
visit(visitor: Visitor, context: any): any {
156155
return visitor.visitComment(this, context);
157156
}
158-
readonly type = 'comment';
157+
readonly kind = 'comment';
159158
}
160159

161160
export class DocType implements BaseNode {
162161
constructor(public value: string|null, public sourceSpan: ParseSourceSpan) {}
163162
visit(visitor: Visitor, context: any): any {
164163
return visitor.visitDocType(this, context);
165164
}
166-
readonly type = 'docType';
165+
readonly kind = 'docType';
167166
}
168167

169168
export class Block extends NodeWithI18n {
@@ -184,7 +183,7 @@ export class Block extends NodeWithI18n {
184183
return visitor.visitBlock(this, context);
185184
}
186185

187-
readonly type = 'block';
186+
readonly kind = 'block';
188187
}
189188

190189
export class Component extends NodeWithI18n {
@@ -208,7 +207,7 @@ export class Component extends NodeWithI18n {
208207
return visitor.visitComponent(this, context);
209208
}
210209

211-
readonly type = 'component';
210+
readonly kind = 'component';
212211
}
213212

214213
export class Directive implements BaseNode {
@@ -224,7 +223,7 @@ export class Directive implements BaseNode {
224223
return visitor.visitDirective(this, context);
225224
}
226225

227-
readonly type = 'directive';
226+
readonly kind = 'directive';
228227
}
229228

230229
export class BlockParameter implements BaseNode {
@@ -237,7 +236,7 @@ export class BlockParameter implements BaseNode {
237236
return visitor.visitBlockParameter(this, context);
238237
}
239238

240-
readonly type = 'blockParameter';
239+
readonly kind = 'blockParameter';
241240
readonly startSourceSpan: null = null;
242241
readonly endSourceSpan: null = null;
243242
}
@@ -255,7 +254,7 @@ export class LetDeclaration implements BaseNode {
255254
return visitor.visitLetDeclaration(this, context);
256255
}
257256

258-
readonly type = 'letDeclaration';
257+
readonly kind = 'letDeclaration';
259258
readonly startSourceSpan: null = null;
260259
readonly endSourceSpan: null = null;
261260
}

0 commit comments

Comments
 (0)