Skip to content

No TDZ-safe hoisting of consts referenced by emitted Ivy definitions #287

@brandonroberts

Description

@brandonroberts

When an emitted Ivy definition eagerly references a const declared after the class, OXC leaves the const in place, producing a temporal-dead-zone ReferenceError at module load.

Repro

import { Component } from '@angular/core';
@Component({ selector: 'x', template: '', providers: [{ provide: TOKEN, useValue: 1 }] })
export class TestComponent {}
const TOKEN = 'tok';

Actual

TOKEN stays after the class; ɵcmp's ɵɵProvidersFeature evaluates eagerly in the class body → ReferenceError: Cannot access 'TOKEN' before initialization.

Expected

Angular hoists consts that emitted definitions depend on above the class declaration.

Impact

Hard runtime crash at module evaluation.


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