I am experimenting with TypeScript, and in the process of creating a class with an "ID" field, which should be an integer, I got a little confused.
First, in Visual Studio 2012 with the TypeScript plugin, I see "int" in the list of intelliSense types. But I get a compilation error that says that the "name" int "does not exist in the current scope."
I reviewed the language specifications and looked only at the following primitive types: number, string, boolean, null, and undefined. No integer type.
So, I have two questions left:
How can I tell users of my class that a particular field is not just a "number", but an integer (and never a floating point or decimal)?
Why do I see "int" in the intellisense list if it is not a valid type?
Update. All the answers I have received so far regarding how JavaScript does not have an int type, it would be difficult to provide an int type at runtime ... I know all this. I ask if there is a TypeScript way to provide annotation to users of my class that this field should be an integer. Perhaps a comment of some specific format?
typescript
Josh Oct 15 '12 at 14:25 2012-10-15 14:25
source share