Skip to content

fix(compiler-cli): escape template literal in TCB#67678

Open
crisbeto wants to merge 1 commit intoangular:mainfrom
crisbeto:67675/escape-template-literal
Open

fix(compiler-cli): escape template literal in TCB#67678
crisbeto wants to merge 1 commit intoangular:mainfrom
crisbeto:67675/escape-template-literal

Conversation

@crisbeto
Copy link
Member

Fixes a regression introduced by #67381 where we weren't escaping backticks in template literals.

Fixes #67675.

@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer target: patch This PR is targeted for the next patch release labels Mar 13, 2026
@angular-robot angular-robot bot added the area: compiler Issues related to `ngc`, Angular's template compiler label Mar 13, 2026
@ngbot ngbot bot added this to the Backlog milestone Mar 13, 2026
@crisbeto crisbeto requested a review from atscott March 13, 2026 09:36
Copy link
Member

@JoostK JoostK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test in https://github.com/angular/angular/blob/main/packages/compiler-cli/test/ngtsc/template_typecheck_spec.ts would be meaningful to verify the template is checked as expected;

@Component({
  template: `
    @let var = `Version: \`${check(version)}\``;
  `
})
export class Cmp {
  version = 'test'
  check(input: number): string {
    return String(input);
  }
}

Should report a type assignability error from string to number. That shows that the template's substitutions are type-checked as expected.

Fixes a regression introduced by angular#67381 where we weren't escaping backticks in template literals.

Fixes angular#67675.
@crisbeto crisbeto force-pushed the 67675/escape-template-literal branch from a5b4ef7 to 1729e55 Compare March 15, 2026 21:27
@crisbeto
Copy link
Member Author

crisbeto commented Mar 15, 2026

Added the extra test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: compiler Issues related to `ngc`, Angular's template compiler target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

double escaped backtick in template literal string in template html breaks from @angular/ v21.2.2

2 participants