Skip to content

Allow bigint literals in templates #44852

Closed

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.

Activity

  1. added this to the needsTriage milestone on Jan 27, 2022
  2. added
    featureLabel used to distinguish feature request from other issues
    on Jan 27, 2022
  3. modified the milestones: needsTriage, Backlog on Jan 27, 2022
  4. Grubba27 commented on Jan 27, 2022

    @Grubba27

    I would like to give it a try, it is on compiler parser ? ?

  5. JoostK commented on Jan 27, 2022

    @JoostK
    Member

    @Grubba27 we haven't made a decision if we want to support this in Angular templates, so I'd hold off from creating a PR for now.

  6. angular-robot commented on Jan 28, 2022

    @angular-robot
    Contributor

    This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

    You can find more details about the feature request process in our documentation.

  7. angular-robot commented on Mar 8, 2022

    @angular-robot
    Contributor

    Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

    Find more details about Angular's feature request process in our documentation.

  8. angular-robot commented on Mar 28, 2022

    @angular-robot
    Contributor

    Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

    We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

    You can find more details about the feature request process in our documentation.

  9. jessicajaniuk commented on Apr 20, 2022

    @jessicajaniuk
    Contributor

    I've added this one to the overarching issue of #43485 where we are tracking all of the potential improvements to the template syntax. I'll close this issue, and we'll track progress on the other issue.

  10. angular-automatic-lock-bot commented on May 21, 2022

    @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.

  11. locked and limited conversation to collaborators on May 21, 2022
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

    area: compilerIssues related to `ngc`, Angular's template compilerarea: coreIssues related to the framework runtimecore: basic template syntaxfeatureLabel used to distinguish feature request from other issues

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions