Understand 'int', 'integer', 'float', 'double', etc. as 'number' in JSDoc
See original GitHub issueAll numeric-sounding names should probably resolve to number
(maybe only if no other type is defined with such a given name).
Ideas:
[u]int[8|16|32|64]
integer
float
double
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Understand 'int', 'integer', 'float', 'double', etc. as 'number' in ...
I think both TS and JSDoc should have a way of defining a type alias as a subset or superset of an existing...
Read more >Use JSDoc: @type
Overview. The @type tag allows you to provide a type expression identifying the type of value that a symbol may contain, or the...
Read more >How do I check that a number is float or integer?
@Pointy: double precision floats can represent integer values exactly up to 2^53. So it depends if the OP was asking about integer in...
Read more >12 Amazing Types of TypeScript You Need to Know - eduCBA
We can also consider that for all types of no's like float, double, int, long int, etc we have the only number as...
Read more >eslint-plugin-jsdoc - npm
This integer property allows one to add a fixed amount of whitespace at the beginning of the second or later lines of the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This might require a breaking change later if actual ints are added.
Arrays in JS are objects so when you access keys with
x[<key>]
,<key>
can be anything.In TS, it only checks if the key is a number so a
string
key will fail but1.5
is a valid key.Maybe
int
could be implemented somehow like literals. But it’s not feasible to guess if a number is an integer or not on computed variables. Typescript does not know the difference between3/2
and4/2
. One would be afloat
and the other anint
but it is difficult to infer this statically.Being able to set
float
keys on an array and not get an error at compile time and neither at runtime is really bad but I guess that’s how it is for now.