Open illume opened 4 years ago
Most likely eslint-plugin-jsdoc should be fixed to support "map-like object" types instead of forcing object
type which aren't equivalents.
Experimental playground with JS - need to open Errors tab to see reported errors
Or recommend to use Record<string, number>
or {[key: string]: number}
instead, however these are TS specific types and might be not supported by all tooling.
Might be part of the recent changes in 3.8 around how under noImplicitAny
, object
means the non-primitive type instead of Object
. Thoughts @sandersn?
@DanielRosenwasser This has never worked -- Object
is the only thing special-cased with type parameters.
Lowercase object.<string,number>
isn't documented on jsdoc.app. I did a quick node_modules fight of our user test suite, which is a decent selection of popular js libraries:
user [master|✔]$ grep -r '{Object.<' | wc -l
599
✔ user [master|✔]$ grep -r '{object.<' | wc -l
2
Both lowercase hits are from protobufjs/externs/fs.js. I personally don't think this is worth supporting unless the real-world usage rates change, or there is a lot of interest on this issue.
@IllusionMH thanks for the tip about Record. I'm using that for now, since eslint jsdoc doesn't rewrite that type (but gives a type undefined warning), and tsc works.
I could make an issue with eslint-jsdoc... let me know?
Object.<string,number>
worksobject.<string,number>
failsjsdoc eslint likes lower case
object
, see here: https://github.com/gajus/eslint-plugin-jsdoc/blob/master/.README/rules/check-types.md