question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow bigint literals in templates

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
jessicajaniukcommented, Apr 20, 2022

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.

0reactions
angular-automatic-lock-bot[bot]commented, May 21, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Template literals (Template strings) - JavaScript | MDN
Template literals are literals delimited with backtick (`) characters, allowing for multi-line strings, string interpolation with embedded ...
Read more >
How can you only allow valid paths to a nested object in a ...
Try using this type: type GetI18nKeys<T extends keyof I18nNamespace> = T extends unknown ? `${T}.${Extract<keyof I18nNamespace[T], ...
Read more >
How to Use TypeScript Template Literal Types Like a Pro
The actual type of the type variable T can be string, number, boolean, or bigint. Template literal types provide us with the ability...
Read more >
JavaScript Template Literals - W3Schools
Automatic replacing of variables with real values is called string interpolation. Expression Substitution. Template literals allow expressions in strings: ...
Read more >
Documentation - TypeScript 3.2
In TypeScript 3.2, object literals now allow generic spread expressions which ... a BigInt literal by adding an n to the end of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found