How do you specify that a class property is an integer?

后端 未结 8 1181
旧巷少年郎
旧巷少年郎 2020-12-15 02:20

I\'m experimenting with TypeScript, and in the process of creating a class with an ID field that should be an integer, I have gotten a

8条回答
  •  暖寄归人
    2020-12-15 02:47

    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.

提交回复
热议问题