1. I think there is not a direct way to specify whether a number is integer or floating point. In the TypeScript specification section 3.2.1 we can see:

    "...The Number primitive type corresponds to the similarly named JavaScript primitive type and represents double-precision 64-bit format IEEE 754 floating point values..."

  2. I think int is a bug in Visual Studio intelliSense. The correct is number.

Answer from Diullei on Stack Overflow
🌐
Delft Stack
delftstack.com › home › howto › typescript › typescript integer type in typescript
How to Represent Integer in TypeScript | Delft Stack
February 2, 2024 - Python ScipyPythonPython ...ArduinoMySQLMongoDBPostgresSQLiteRVBAScalaRaspberry Pi ... In TypeScript, there is no concept of integer data types like in other programming languages. Only a number type is used to represent ...
🌐
TypeScript Tutorial
typescripttutorial.net › home › typescript tutorial › typescript number
TypeScript Number
October 18, 2024 - The floating-point numbers have the type number while the big integers get the type bigint. The following shows how to declare a variable that holds a floating-point value: let price: number;Code language: JavaScript (javascript) Alternatively, you can initialize the price variable to a number: ...
🌐
Tektutorialshub
tektutorialshub.com › home › typescript › typescript number data type
TypeScript Number Data Type - Tektutorialshub
March 15, 2023 - One is a primitive number data type. The other one is BigInt, which is a recent addition. It does not have separate data types like integers, decimal, float as in the other languages.
🌐
GeeksforGeeks
geeksforgeeks.org › typescript-numbers
TypeScript Numbers - GeeksforGeeks
August 9, 2024 - TypeScript treats numbers as both integers and floating-point values.
🌐
Medium
medium.com › interesting-coding › all-typescript-types-you-need-to-know-dd1423fd6687
All TypeScript Types You Need To Know | by Cihan | Interesting Coding | Medium
November 10, 2023 - In TypeScript, there are several ... boolean: Represents a value that is either true or false. number: Represents a numeric value, either integer or floating-point....
🌐
TutorialsPoint
tutorialspoint.com › typescript › typescript_types.htm
TypeScript - Types
There is no integer type in TypeScript and JavaScript. Now, lets understand each built-in data type in detail. In TypeScript, the number data type can store the integer, floating point, binary, decimal, hexadecimal, etc.
🌐
TutorialsPoint
tutorialspoint.com › typescript › typescript_numbers.htm
TypeScript - Numbers
The Number class acts as a wrapper and enables manipulation of numeric literals as they were objects. TypeScript number type represents the numeric values. All the numbers are represented as the floating point values.
Find elsewhere
Top answer
1 of 2
38

number is only a TypeScript thing - it's a primitive type referring to, well, a number.

But, judging by the error message, it seems that number isn't actually a discrete value like Number.

Indeed - it's a type, so it doesn't exist in emitted code.

a discrete value like Number. On the other hand, user-defined types like classes appear to be discrete values (as they also print the standard function description).

Yes. Classes, of which Number is one, are special. They do two things, somewhat unintuitively:

  • They create a JavaScript class (usable in emitted code)
  • They also create an interface for the class (only used by TypeScript)

If you use Number in a place where a type is expected, TypeScript will not complain, because Number is an interface.

If you use Number in a place where a value (something that exists in emitted code) is expected, TypeScript will not complain, because Number is also a global constructor.

In other words, the two Numbers below refer to completely different things:

// refer to the TypeScript Number interface
let foo: Number;

// refer to the JavaScript global.Number constructor
const someNum = Number(someString);

Using Number in TypeScript is very odd, since it'd, strictly, speaking, refer to a number created via new:

const theNum = new Number(6);

Which there's almost never a reason to do. Use a plain primitive number instead, without an object wrapper.

const theNum = 6;
// theNum is typed as `number`
2 of 2
1

From https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#the-primitives-string-number-and-boolean:

JavaScript has three very commonly used primitives: string, number, and boolean. Each has a corresponding type in TypeScript. As you might expect, these are the same names you’d see if you used the JavaScript typeof operator on a value of those types:

  • string represents string values like "Hello, world"
  • number is for numbers like 42. JavaScript does not have a special runtime value for integers, so there’s no equivalent to int or float - everything is simply number
  • boolean is for the two values true and false

The type names String, Number, and Boolean (starting with capital letters) are legal, but refer to some special built-in types that will very rarely appear in your code. Always use string, number, or boolean for types.

(There are also typs for null and undefined)

🌐
typescriptlang.org
typescriptlang.org › docs › handbook › 2 › everyday-types.html
TypeScript: Documentation - Everyday Types
Each has a corresponding type in TypeScript. As you might expect, these are the same names you’d see if you used the JavaScript typeof operator on a value of those types: string represents string values like "Hello, world" number is for numbers like 42. JavaScript does not have a special runtime value for integers, so there’s no equivalent to int or float - everything is simply number
🌐
TutorialsPoint
tutorialspoint.com › typescript-bigint-vs-number
Typescript BigInt Vs Number
The BigInt data type in JavaScript is a numeric primitive that can represent integers with arbitrary magnitude. This is in contrast to the Number data type, which is limited to representing integers between -(253 - 1) and 253 - 1.
🌐
Tutorial Teacher
tutorialsteacher.com › typescript › typescript-number
TypeScript Data Type - Number
Just like Javascript, Typescript supports number data type. All numbers are stored as floating point numbers. These numbers can be Decimal (base 10), Hexadecimal (base 16) or Octal (base 8).
🌐
Codefinity
codefinity.com › courses › v2 › 3c6ec5e9-886b-465a-b174-93d7470b0c0c › 55bada62-f978-4c4f-bed0-c9e19e1e1e8c › fadf9301-bb43-4ef5-9128-7b4bf1ef9d46
Learn Number Type | Core TypeScript Types
TypeScript uses the number type to represent both integer and floating-point values. This means you do not need to distinguish between whole numbers and decimals—TypeScript treats them all as number.
🌐
LinkedIn
linkedin.com › pulse › number-vs-typescript-tamjid-ahmed
Number vs number in TypeScript
March 11, 2023 - In TypeScript, number refers to the primitive type that represents a numeric value, while Number refers to the global object that can be used to perform mathematical operations and manipulate numeric values.
🌐
The Tombomb
thetombomb.com › posts › typescript-there-are-no-integers
Typescript: There are no integers! - Thomas Desmond
October 8, 2020 - Returned to me was 212.1. And it ... the day. But I want to write this post to help me remember. There is no integer type in Typescript only floating-point!...
🌐
GitBook
basarat.gitbook.io › typescript › recap › number
Number | TypeScript Deep Dive
February 9, 2023 - // Safe value console.log(Number.isSafeInteger(Number.MAX_SAFE_INTEGER)); // true // Unsafe value console.log(Number.isSafeInteger(Number.MAX_SAFE_INTEGER + 1)); // false // Because it might have been rounded to it due to overflow console.log(Number.isSafeInteger(Number.MAX_SAFE_INTEGER + 10)); // false ... import { Big } from 'big.js'; export const foo = new Big('111.11111111111111111111'); export const bar = foo.plus(new Big('0.00000000000000000001')); // To get a number: const x: number = Number(bar.toString()); // Loses the precision
🌐
Atomic Spin
spin.atomicobject.com › 2018 › 11 › 05 › using-an-int-type-in-typescript
Using an Int Type in TypeScript - Atomic Spin
November 5, 2018 - Support for BigInt in TypeScript is on the roadmap for TypeScript 3.2. I suspect that once it’s available I can just change the definition of Int to this: ... This Int type isn’t perfect, but using it will help the compiler prevent you from making the same kind of mistake we made when dealing with JavaScript numbers that really need to be integers.
🌐
Luis Llamas
luisllamas.es › inicio › cursos › curso typescript
The Number Type in TypeScript
June 23, 2025 - In TypeScript, the number type is used to represent numbers, both integers and floating-point.