Skip to content

${...} template-literal interpolation in decorator metadata not statically evaluated #286

@brandonroberts

Description

@brandonroberts

When a decorator's template: or selector: is a JS template literal interpolating a module-level const, OXC fails to evaluate it — either bailing entirely (no ɵcmp) or compiling with an unresolved selector.

Repro

import { Component } from '@angular/core';
const twBtn = `px-4 py-2 rounded`;
@Component({ selector: 'app-btn', template: `<button class="${twBtn}">x</button>` })
export class BtnComponent {}

Actual

Emits the verbatim @Component source — no ɵcmp. With ${...} in selector:, compiles but emits selectors: [["ng-component"]].

Expected

Angular's partial evaluator resolves const-bound (incl. nested/chained) template literals in static metadata fields. OXC already handles styles: correctly — only template:/selector: regress. Commit a2e5d4d (#271) covered plain string consts but not template-literal consts.

Impact

AOT — an uncompiled component is dead at runtime; an unresolved selector silently never matches its tag.


Researched and drafted with Claude Code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions