diff --git a/packages/localize/src/localize/src/localize.ts b/packages/localize/src/localize/src/localize.ts index 660b4e2538..dbed0e879f 100644 --- a/packages/localize/src/localize/src/localize.ts +++ b/packages/localize/src/localize/src/localize.ts @@ -159,25 +159,12 @@ const BLOCK_MARKER = ':'; * escaped with a backslash, `\:`. This function checks for this by looking at the `raw` * messagePart, which should still contain the backslash. * - * --- - * - * If the template literal was synthesized and downleveled by TypeScript to ES5 then its - * raw array will only contain empty strings. This is because the current TypeScript compiler uses - * the original source code to find the raw text and in the case of synthesized AST nodes, there is - * no source code to draw upon. - * - * The workaround in this function is to assume that the template literal did not contain an escaped - * placeholder name, and fall back on checking the cooked array instead. - * This is a limitation if compiling to ES5 in TypeScript but is not a problem if the TypeScript - * output is ES2015 and the code is downleveled by a separate tool as happens in the Angular CLI. - * * @param messagePart The cooked message part to process. * @param rawMessagePart The raw message part to check. * @returns the message part with the placeholder name stripped, if found. * @throws an error if the block is unterminated */ function stripBlock(messagePart: string, rawMessagePart: string) { - rawMessagePart = rawMessagePart || messagePart; return rawMessagePart.charAt(0) === BLOCK_MARKER ? messagePart.substring(findEndOfBlock(messagePart, rawMessagePart) + 1) : messagePart; diff --git a/packages/localize/src/utils/src/messages.ts b/packages/localize/src/utils/src/messages.ts index 5188caa1d2..6664b4db67 100644 --- a/packages/localize/src/utils/src/messages.ts +++ b/packages/localize/src/utils/src/messages.ts @@ -182,18 +182,6 @@ export function parseMetadata(cooked: string, raw: string): MessageMetadata { * Since blocks are optional, it is possible that the content of a message block actually starts * with a block marker. In this case the marker must be escaped `\:`. * - * --- - * - * If the template literal was synthesized and downleveled by TypeScript to ES5 then its - * raw array will only contain empty strings. This is because the current TypeScript compiler uses - * the original source code to find the raw text and in the case of synthesized AST nodes, there is - * no source code to draw upon. - * - * The workaround in this function is to assume that the template literal did not contain an escaped - * placeholder name, and fall back on checking the cooked array instead. - * This is a limitation if compiling to ES5 in TypeScript but is not a problem if the TypeScript - * output is ES2015 and the code is downlevelled by a separate tool as happens in the Angular CLI. - * * @param cooked The cooked version of the message part to parse. * @param raw The raw version of the message part to parse. * @returns An object containing the `text` of the message part and the text of the `block`, if it @@ -201,7 +189,6 @@ export function parseMetadata(cooked: string, raw: string): MessageMetadata { * @throws an error if the `block` is unterminated */ export function splitBlock(cooked: string, raw: string): {text: string, block?: string} { - raw = raw || cooked; if (raw.charAt(0) !== BLOCK_MARKER) { return {text: cooked}; } else { diff --git a/packages/localize/src/utils/test/messages_spec.ts b/packages/localize/src/utils/test/messages_spec.ts index 2167e8cfdd..5c7be42d9c 100644 --- a/packages/localize/src/utils/test/messages_spec.ts +++ b/packages/localize/src/utils/test/messages_spec.ts @@ -61,12 +61,6 @@ describe('messages utils', () => { expect(message.messageId).toEqual('2623373088949454037'); }); - it('should handle raw values that are empty (from synthesized AST)', () => { - const message = - parseMessage(makeTemplateObject(['a', ':one:b', ':two:c'], ['', '', '']), [1, 2]); - expect(message.messageId).toEqual('8865273085679272414'); - }); - it('should extract the meaning, description and placeholder names', () => { const message1 = parseMessage(makeTemplateObject(['abc'], ['abc']), []); expect(message1.messageParts).toEqual(['abc']); @@ -128,10 +122,6 @@ describe('messages utils', () => { ':block with escaped : in it:abc def', ':block with escaped \\: in it:abc def')) .toEqual({text: 'abc def', block: 'block with escaped : in it'}); }); - - it('should handle the empty raw part', () => { - expect(splitBlock(':block info:abc def', '')).toEqual({text: 'abc def', block: 'block info'}); - }); }); describe('findEndOfBlock()', () => { @@ -193,11 +183,5 @@ describe('messages utils', () => { id: undefined }); }); - - it('should handle the empty raw part', () => { - expect(parseMetadata(':description:abc def', '')) - .toEqual( - {text: 'abc def', meaning: undefined, description: 'description', id: undefined}); - }); }); });