Skip to content

Latest commit

 

History

History
61 lines (45 loc) · 2.47 KB

no-undefined-types.md

File metadata and controls

61 lines (45 loc) · 2.47 KB

no-undefined-types

Checks that types in jsdoc comments are defined. This can be used to check unimported types.

When enabling this rule, types in jsdoc comments will resolve as used variables, i.e. will not be marked as unused by no-unused-vars.

In addition to considering globals found in code (or in ESLint-indicated globals) as defined, the following tags will also be checked for name(path) definitions to also serve as a potential "type" for checking the tag types in the table below:

@callback, @class (or @constructor), @constant (or @const), @event, @external (or @host), @function (or @func or @method), @interface, @member (or @var), @mixin, @name, @namespace, @template (for "closure" or "typescript" settings.jsdoc.mode only), @typedef.

The following tags will also be checked but only when the mode is closure:

@package, @private, @protected, @public, @static

The following types are always considered defined.

  • null, undefined, void, string, boolean, object, function, symbol
  • number, bigint, NaN, Infinity
  • any, *
  • Array, Object, RegExp, Date, Function

Note that preferred types indicated within settings.jsdoc.preferredTypes will also be assumed to be defined.

Also note that if there is an error parsing types for a tag, the function will silently ignore that tag, leaving it to the valid-types rule to report parsing errors.

If you define your own tags, you can use settings.jsdoc.structuredTags to indicate that a tag's name is "namepath-defining" (and should prevent reporting on use of that namepath elsewhere) and/or that a tag's type is false (and should not be checked for types).

Options

An option object may have the following key:

  • definedTypes - This array can be populated to indicate other types which are automatically considered as defined (in addition to globals, etc.). Defaults to an empty array.
Context everywhere
Tags augments, class, constant, enum, implements, member, module, namespace, param, property, returns, throws, type, typedef, yields
Aliases constructor, const, extends, var, arg, argument, prop, return, exception, yield
Closure-only package, private, protected, public, static
Options definedTypes
Settings preferredTypes, mode, structuredTags