Skip to content

JSDoc & TSDoc Tags

JSDoc or TSDoc tags can be used to make exceptions for unused or duplicate exports.

Knip tries to minimize configuration and introduces no new syntax. That’s why it hooks into JSDoc and TSDoc tags.

JSDoc comments always start with /** (not //) and can be single or multi-line.

Tags (CLI)

Use arbitrary tags to exclude or include tagged exports from the report. Example:

/** @knipignore */
export const myUnusedExport = 1;
/** @knipignore */
import Unresolved from './generated/lib.js';

And then include (+) or exclude (-) these tagged exports from the report like so:

Terminal window
knip --tags=-knipignore,-internal


By default, Knip reports unused exports in non-entry files.

Tag the export as @public and Knip will not report it.


* @public
export const unusedFunction = () => {};

This tag can also be used to make exceptions in entry files when using —include-entry-exports.

JSDoc: @public and TSDoc: @public


Internal exports are not meant for public consumption, but only for internal usage such as tests. This means they would be reported in production mode.

Mark the export with @internal and Knip will not report the export in production mode.


/** @internal */
export const internalTestedFunction = () => {};

In general it’s not recommended to expose and test implementation details, but exceptions are possible. Those should not be reported as false positives, so when using production mode you’ll need to help Knip out by tagging them as @internal.

TSDoc: @internal


Knip reports duplicate exports. To prevent this, tag one of the exports as @alias.


export const Component = () => {};
/** @alias */
export default Component;

An alternative solution is to use --exclude duplicates and exclude all duplicates from being reported.

JSDoc: @alias


Works identical to @public. Knip ignores other tags like @alpha and @experimental.

TSDoc: @beta

ISC License © 2024 Lars Kappert