Skip to content

Allow bigint literals in templates #44852

@SadiinsoSnowfall

Description

@SadiinsoSnowfall

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

compiler

Description

Currently, templates does not seems to support bigint literals.
Because of that, the following code does not compiles:

<!-- Argument of type 'number' is not assignable to parameter of type 'bigint'. -->
<button (click)="onClick(55n)"></button>
onClick(v: bigint) {
    console.log("clicked %o", v);
}

The only way to get this to work it to either

  • re-export the BigInt function from the component code
  • use a variable defined in the component code
<button (click)="onClick(BigInt(55))"></button>
<button (click)="onClick(aBigInt)"></button>
BigInt = BigInt;
aBigInt = 55n:

onClick(v: bigint) {
    console.log("clicked %o", v);
}

Proposed solution

Allow bigint literals (ending with n) in the templates and treat them as bigint not number.

Alternatives considered

Change nothing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilerIssues related to `ngc`, Angular's template compilerarea: coreIssues related to the framework runtimecore: basic template syntaxfeatureIssue that requests a new feature

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions