refactor(compiler): add source-map spans to localized strings (#32912)

Previously localized strings were not mapped to their original
source location, so it was not possible to back-trace them
in tools like the i18n message extractor.

PR Close #32912
This commit is contained in:
Pete Bacon Darwin
2020-06-18 11:49:18 +01:00
committed by Andrew Kushnir
parent decd95e7f0
commit dda3f49952
2 changed files with 17 additions and 7 deletions

View File

@ -274,9 +274,11 @@ class ExpressionTranslatorVisitor implements ExpressionVisitor, StatementVisitor
}
visitLocalizedString(ast: LocalizedString, context: Context): ts.Expression {
return this.scriptTarget >= ts.ScriptTarget.ES2015 ?
const localizedString = this.scriptTarget >= ts.ScriptTarget.ES2015 ?
createLocalizedStringTaggedTemplate(ast, context, this) :
createLocalizedStringFunctionCall(ast, context, this, this.imports);
this.setSourceMapRange(localizedString, ast);
return localizedString;
}
visitExternalExpr(ast: ExternalExpr, context: Context): ts.PropertyAccessExpression