Skip to content

Commit d4ef207

Browse files
JeanMechethePunderWoman
authored andcommitted
refactor(compiler): handle #24571 todos. (#49220)
This commit removes the remaining TODO(issue/24571) in compiler code base. PR Close #49220
1 parent 34b796f commit d4ef207

File tree

10 files changed

+16
-46
lines changed

10 files changed

+16
-46
lines changed

packages/compiler/src/constant_pool.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ const POOL_INCLUSION_LENGTH_THRESHOLD_FOR_STRINGS = 50;
4646
class FixupExpression extends o.Expression {
4747
private original: o.Expression;
4848

49-
// TODO(issue/24571): remove '!'.
50-
shared!: boolean;
49+
shared = false;
5150

5251
constructor(public resolved: o.Expression) {
5352
super(resolved.type);

packages/compiler/src/i18n/extractor_merger.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,44 +56,33 @@ enum _VisitorMode {
5656
* @internal
5757
*/
5858
class _Visitor implements html.Visitor {
59-
// TODO(issue/24571): remove '!'.
59+
// Using non-null assertions because all variables are (re)set in init()
60+
6061
private _depth!: number;
6162

6263
// <el i18n>...</el>
63-
// TODO(issue/24571): remove '!'.
6464
private _inI18nNode!: boolean;
65-
// TODO(issue/24571): remove '!'.
6665
private _inImplicitNode!: boolean;
6766

6867
// <!--i18n-->...<!--/i18n-->
69-
// TODO(issue/24571): remove '!'.
7068
private _inI18nBlock!: boolean;
71-
// TODO(issue/24571): remove '!'.
7269
private _blockMeaningAndDesc!: string;
73-
// TODO(issue/24571): remove '!'.
7470
private _blockChildren!: html.Node[];
75-
// TODO(issue/24571): remove '!'.
7671
private _blockStartDepth!: number;
7772

7873
// {<icu message>}
79-
// TODO(issue/24571): remove '!'.
8074
private _inIcu!: boolean;
8175

8276
// set to void 0 when not in a section
8377
private _msgCountAtSectionStart: number|undefined;
84-
// TODO(issue/24571): remove '!'.
8578
private _errors!: I18nError[];
86-
// TODO(issue/24571): remove '!'.
8779
private _mode!: _VisitorMode;
8880

8981
// _VisitorMode.Extract only
90-
// TODO(issue/24571): remove '!'.
9182
private _messages!: i18n.Message[];
9283

9384
// _VisitorMode.Merge only
94-
// TODO(issue/24571): remove '!'.
9585
private _translations!: TranslationBundle;
96-
// TODO(issue/24571): remove '!'.
9786
private _createI18nMessage!: I18nMessageFactory;
9887

9988

packages/compiler/src/i18n/i18n_ast.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,9 @@ export class Container implements Node {
8989
}
9090

9191
export class Icu implements Node {
92-
// TODO(issue/24571): remove '!'.
93-
public expressionPlaceholder!: string;
9492
constructor(
9593
public expression: string, public type: string, public cases: {[k: string]: Node},
96-
public sourceSpan: ParseSourceSpan) {}
94+
public sourceSpan: ParseSourceSpan, public expressionPlaceholder?: string) {}
9795

9896
visit(visitor: Visitor, context?: any): any {
9997
return visitor.visitIcu(this, context);
@@ -162,8 +160,7 @@ export class CloneVisitor implements Visitor {
162160
visitIcu(icu: Icu, context?: any): Icu {
163161
const cases: {[k: string]: Node} = {};
164162
Object.keys(icu.cases).forEach(key => cases[key] = icu.cases[key].visit(this, context));
165-
const msg = new Icu(icu.expression, icu.type, cases, icu.sourceSpan);
166-
msg.expressionPlaceholder = icu.expressionPlaceholder;
163+
const msg = new Icu(icu.expression, icu.type, cases, icu.sourceSpan, icu.expressionPlaceholder);
167164
return msg;
168165
}
169166

packages/compiler/src/i18n/serializers/xliff.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,9 @@ class _WriteVisitor implements i18n.Visitor {
178178
// TODO(vicb): add error management (structure)
179179
// Extract messages as xml nodes from the xliff file
180180
class XliffParser implements ml.Visitor {
181-
// TODO(issue/24571): remove '!'.
181+
// using non-null assertions because they're re(set) by parse()
182182
private _unitMlString!: string|null;
183-
// TODO(issue/24571): remove '!'.
184183
private _errors!: I18nError[];
185-
// TODO(issue/24571): remove '!'.
186184
private _msgIdToHtml!: {[msgId: string]: string};
187185
private _locale: string|null = null;
188186

@@ -270,7 +268,7 @@ class XliffParser implements ml.Visitor {
270268

271269
// Convert ml nodes (xliff syntax) to i18n nodes
272270
class XmlToI18n implements ml.Visitor {
273-
// TODO(issue/24571): remove '!'.
271+
// using non-null assertion because it's re(set) by convert()
274272
private _errors!: I18nError[];
275273

276274
convert(message: string, url: string) {

packages/compiler/src/i18n/serializers/xliff2.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ export class Xliff2 extends Serializer {
114114
}
115115

116116
class _WriteVisitor implements i18n.Visitor {
117-
// TODO(issue/24571): remove '!'.
118-
private _nextPlaceholderId!: number;
117+
private _nextPlaceholderId = 0;
119118

120119
visitText(text: i18n.Text, context?: any): xml.Node[] {
121120
return [new xml.Text(text.value)];
@@ -195,11 +194,9 @@ class _WriteVisitor implements i18n.Visitor {
195194

196195
// Extract messages as xml nodes from the xliff file
197196
class Xliff2Parser implements ml.Visitor {
198-
// TODO(issue/24571): remove '!'.
197+
// using non-null assertions because they're all (re)set by parse()
199198
private _unitMlString!: string|null;
200-
// TODO(issue/24571): remove '!'.
201199
private _errors!: I18nError[];
202-
// TODO(issue/24571): remove '!'.
203200
private _msgIdToHtml!: {[msgId: string]: string};
204201
private _locale: string|null = null;
205202

@@ -293,7 +290,7 @@ class Xliff2Parser implements ml.Visitor {
293290

294291
// Convert ml nodes (xliff syntax) to i18n nodes
295292
class XmlToI18n implements ml.Visitor {
296-
// TODO(issue/24571): remove '!'.
293+
// using non-null assertion because re(set) by convert()
297294
private _errors!: I18nError[];
298295

299296
convert(message: string, url: string) {

packages/compiler/src/i18n/serializers/xtb.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,9 @@ function createLazyProperty(messages: any, id: string, valueFn: () => any) {
8080

8181
// Extract messages as xml nodes from the xtb file
8282
class XtbParser implements ml.Visitor {
83-
// TODO(issue/24571): remove '!'.
83+
// using non-null assertions because they're (re)set by parse()
8484
private _bundleDepth!: number;
85-
// TODO(issue/24571): remove '!'.
8685
private _errors!: I18nError[];
87-
// TODO(issue/24571): remove '!'.
8886
private _msgIdToHtml!: {[msgId: string]: string};
8987
private _locale: string|null = null;
9088

@@ -161,7 +159,7 @@ class XtbParser implements ml.Visitor {
161159

162160
// Convert ml nodes (xtb syntax) to i18n nodes
163161
class XmlToI18n implements ml.Visitor {
164-
// TODO(issue/24571): remove '!'.
162+
// using non-null assertion because it's (re)set by convert()
165163
private _errors!: I18nError[];
166164

167165
convert(message: string, url: string) {

packages/compiler/src/i18n/translation_bundle.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ export class TranslationBundle {
6262
}
6363

6464
class I18nToHtmlVisitor implements i18n.Visitor {
65-
// TODO(issue/24571): remove '!'.
65+
// using non-null assertions because they're (re)set by convert()
6666
private _srcMsg!: i18n.Message;
67-
private _contextStack: {msg: i18n.Message, mapper: (name: string) => string}[] = [];
6867
private _errors: I18nError[] = [];
69-
// TODO(issue/24571): remove '!'.
68+
private _contextStack: {msg: i18n.Message, mapper: (name: string) => string}[] = [];
7069
private _mapper!: (name: string) => string;
7170

7271
constructor(

packages/compiler/src/ml_parser/xml_tags.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ import {TagContentType, TagDefinition} from './tags';
1010

1111
export class XmlTagDefinition implements TagDefinition {
1212
closedByParent: boolean = false;
13-
// TODO(issue/24571): remove '!'.
14-
requiredParents!: {[key: string]: boolean};
15-
// TODO(issue/24571): remove '!'.
16-
parentToAdd!: string;
17-
// TODO(issue/24571): remove '!'.
18-
implicitNamespacePrefix!: string;
13+
implicitNamespacePrefix: string|null = null;
1914
isVoid: boolean = false;
2015
ignoreFirstLf: boolean = false;
2116
canSelfClose: boolean = true;

packages/compiler/test/expression_parser/utils/unparser.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ import {DEFAULT_INTERPOLATION_CONFIG, InterpolationConfig} from '../../../src/ml
1111

1212
class Unparser implements AstVisitor {
1313
private static _quoteRegExp = /"/g;
14-
// TODO(issue/24571): remove '!'.
14+
// using non-null assertion because they're both re(set) by unparse()
1515
private _expression!: string;
16-
// TODO(issue/24571): remove '!'.
1716
private _interpolationConfig!: InterpolationConfig;
1817

1918
unparse(ast: AST, interpolationConfig: InterpolationConfig) {

packages/compiler/test/integration_spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
2020
it('should support dotted selectors', waitForAsync(() => {
2121
@Directive({selector: '[dot.name]'})
2222
class MyDir {
23-
// TODO(issue/24571): remove '!'.
2423
@Input('dot.name') value!: string;
2524
}
2625

0 commit comments

Comments
 (0)