← Back

jsdoc/check-types warning

Reports invalid types.

By default, ensures that the casing of native types is the same as in this list:

  • undefined
  • null
  • boolean
  • number
  • bigint
  • string
  • symbol
  • object
  • Array
  • Function
  • Date
  • RegExp

Examples

❌  Incorrect

/**
 * @param {Number} foo
 */
function quux1 (foo) {

}
// Message: Invalid JSDoc @param "foo" type "Number"; prefer: "number".

/**
 * @arg {Number} foo
 */
function quux2 (foo) {

}
// Message: Invalid JSDoc @arg "foo" type "Number"; prefer: "number".

/**
 * @returns {Number} foo
 * @throws {Number} foo
 */
function quux3 () {

}
// Message: Invalid JSDoc @returns type "Number"; prefer: "number".

/**
 * @param {(Number|string|Boolean)=} foo
 */
function quux4 (foo, bar, baz) {

}
// Message: Invalid JSDoc @param "foo" type "Number"; prefer: "number".

/**
 * @param {Array.<Number|String>} foo
 */
function quux5 (foo, bar, baz) {

}
// Message: Invalid JSDoc @param "foo" type "Number"; prefer: "number".

/**
 * @param {(Number|String)[]} foo
 */
function quux6 (foo, bar, baz) {

}
// Message: Invalid JSDoc @param "foo" type "Number"; prefer: "number".

✅  Correct

/**
 * @param {number} foo
 * @param {Bar} bar
 * @param {*} baz
 */
function quux1 (foo, bar, baz) {

}

/**
 * @arg {number} foo
 * @arg {Bar} bar
 * @arg {*} baz
 */
function quux2 (foo, bar, baz) {

}

/**
 * @param {(number|string|boolean)=} foo
 */
function quux3 (foo, bar, baz) {

}

/**
 * @param {typeof bar} foo
 */
function qux1(foo) {
}

/**
 * @param {import('./foo').bar.baz} foo
 */
function qux2(foo) {
}

/**
 * @param {(x: number, y: string) => string} foo
 */
function qux3(foo) {
}

/**
 * @param {() => string} foo
 */
function qux4(foo) {
}