Allow bigint literals in templates
See original GitHub issueWhich @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:
- Created 2 years ago
- Reactions:9
- Comments:7 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.