Skip to content

feat(template): support optional type annotations in @let declarations #66651

Closed as duplicate

Description

@cesco69

Which @angular/* package(s) are relevant/related to the feature request?

core

Description

Extend the @let template declaration syntax to support optional type annotations, similar to TypeScript variable declarations:

@let myVar: MyType = myAny;

Eg.:

type MyType = { foo: boolean };

@Component({
  selector: 'app-root',
  template: `
    @let myVar: MyType = myAny;

    {{ myVar.foo }}
  `,
})
export class App {
  MyType!: MyType;
  myAny: any = { foo: true };
}

Proposed solution

@let myVar: MyType = myAny;

Alternatives considered

@let myVar = myAny as MyType;

OR

some trick for declare type into template like JSDOC???

type MyType = { foo: boolean };

@Component({
  selector: 'app-root',
  template: `
    <!-- @type { MyType } -->
    @let myVar = myAny;

    {{ myVar.foo }}
  `,
})
export class App {
  MyType!: MyType;
  myAny: any = { foo: true };
}

Activity

  1. JeanMeche commented on Jan 20, 2026

    @JeanMeche
    Member

    This falls under #43485. Right now templates don't see any symbols that are not class members.

  2. angular-automatic-lock-bot commented on Feb 20, 2026

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  3. locked and limited conversation to collaborators on Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions