Search Terms
int double, integer, float, double
Suggestion
This proposal introduces new number types int and double or float. Goal is to make a difference between integers and floating point numbers since some JavaScript engines does such kind of difference in the back-end.
Use Cases
As we know about V8 engine, it uses pointer tagging to distinguish between different types such as Smi (small integer), HeapObject, WeakHeapObject etc.
Consider this example:
const o1 = {};
o1.x = 3;
o1.y = 4;
const o2 = {};
o2.x = 5;
o2.y = 6;
For both o1 and o2 object the engine will create same shapes. See image below:

However, after changing o2.x to some double value, say that o2.x = 5.5; then V8 will use create new subtree from that shape and the old subtree in this shape will be marked as deprecated and will be garbage-collected. Reason for this is because there is a difference how V8 stores Smi and Double values in the memory.
Here is second image after changing x to 5.5:

Read more here: https://ponyfoo.com/articles/javascript-performance-pitfalls-v8#smi-to-double-migrations
Examples
Some code examples from the proposal:
class Point {
constructor(private x: int, private y: int) {}
getX(): int { this.x = x; }
getY(): int { this.y = y; }
}
let point = new Point(12, 5);
point.x = 1.5; // Error: double is not assignable to integer
This proposal does not require a breaking change, since number types are also okay, if one considers some possible performance pitfalls.
Checklist
My suggestion meets these guidelines:
Search Terms
int double, integer, float, double
Suggestion
This proposal introduces new number types
intanddoubleorfloat. Goal is to make a difference between integers and floating point numbers since some JavaScript engines does such kind of difference in the back-end.Use Cases
As we know about V8 engine, it uses pointer tagging to distinguish between different types such as
Smi(small integer),HeapObject,WeakHeapObjectetc.Consider this example:
For both
o1ando2object the engine will create same shapes. See image below:However, after changing
o2.xto some double value, say thato2.x = 5.5;then V8 will use create new subtree from that shape and the old subtree in this shape will be marked as deprecated and will be garbage-collected. Reason for this is because there is a difference how V8 storesSmiandDoublevalues in the memory.Here is second image after changing
xto5.5:Read more here: https://ponyfoo.com/articles/javascript-performance-pitfalls-v8#smi-to-double-migrations
Examples
Some code examples from the proposal:
This proposal does not require a breaking change, since
numbertypes are also okay, if one considers some possible performance pitfalls.Checklist
My suggestion meets these guidelines: