mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(compiler): Remove invalid assertion about i18n params (#53300)
We previously had an assertion that every placeholder in the i18n AST had a corresponding param in the output. However, there are some cases such as interpolations nested inside ICUs where this assertion is not true. This change simply removes the asserion. PR Close #53300
This commit is contained in:
committed by
Dylan Hunn
parent
a9e8c3cb0b
commit
5ce3190da7
+1
-2
@@ -190,8 +190,7 @@
|
||||
"verifyUniqueConsts"
|
||||
]
|
||||
}
|
||||
],
|
||||
"skipForTemplatePipeline": true
|
||||
]
|
||||
},
|
||||
{
|
||||
"description": "should handle icus with named interpolations",
|
||||
|
||||
@@ -99,9 +99,6 @@ function collectMessage(
|
||||
// Sort the params for consistency with TemaplateDefinitionBuilder output.
|
||||
messageOp.params = new Map([...messageOp.params.entries()].sort());
|
||||
|
||||
// Check that the message has all of its parameters filled out.
|
||||
assertAllParamsResolved(messageOp);
|
||||
|
||||
const mainVar = o.variable(job.pool.uniqueName(TRANSLATION_VAR_PREFIX));
|
||||
// Closure Compiler requires const names to start with `MSG_` but disallows any other
|
||||
// const to start with `MSG_`. We define a variable starting with `MSG_` just for the
|
||||
@@ -230,21 +227,3 @@ function i18nGenerateClosureVar(
|
||||
}
|
||||
return o.variable(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that all of the message's placeholders have values.
|
||||
*/
|
||||
function assertAllParamsResolved(op: ir.I18nMessageOp): asserts op is ir.I18nMessageOp {
|
||||
for (let placeholder in op.message.placeholders) {
|
||||
placeholder = placeholder.trimEnd();
|
||||
if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
|
||||
throw Error(`Failed to resolve i18n placeholder: ${placeholder}`);
|
||||
}
|
||||
}
|
||||
for (let placeholder in op.message.placeholderToMessage) {
|
||||
placeholder = placeholder.trimEnd();
|
||||
if (!op.params.has(placeholder) && !op.postprocessingParams.has(placeholder)) {
|
||||
throw Error(`Failed to resolve i18n message placeholder: ${placeholder}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user