Skip to content

[Feature] Support stringified via tags numeric literals #2480

Open
@MaxGraey

Description

@MaxGraey

Examples

const a = u32`0xFF` // same as u32(0xFF), <u32>0xFF, 0xFF as u32
const b = f64`-1e5` // ^
// etc

Motivation

It will allow support non-standard for TypeScript / JavaScript literal formats like hexadecimal floating points:

f64`0x1.2afep+34`
f32`0x1.0-2`

If you allow you to create custom tags, it could also be useful for third-party libraries. Possible examples:

u128`170141183460469231731687303715884105728`;
bigint`10889035741470030830827987437816582766592`;
deg`45`; // may convert to 0.7853981634 radians inplace
min`5`; // may convert to 300000 ms inplace 

For MVP we can implement only tags for builtin types without custom defined tags

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions