Skip to content

[require-template]: false negative to TypeScript overload function #1462

@otomad

Description

@otomad

Expected behavior

It should report error to type parameters of the overloaded functions when jsdoc doesn't declare @template.

Actual behavior

Nothing reported.

ESLint Config

export default [
	tseslint.configs.base,
	{
		files: ["**/*.{js,ts}"],
		plugins: {
			jsdoc,
		},
		rules: {
			"jsdoc/require-template": ["error", {
				"requireSeparateTemplates": true,
			}],
		},
	},
];

ESLint sample

This will not report any error.

/**
 * @param bar
 * @param baz
 * @returns
 */
function foo<T>(bar: T, baz: number): T;
function foo<T>(bar: T, baz: boolean): T;
function foo<T>(bar: T, baz: number | boolean): T {
	return bar;
}

This will report the error properly.

function foo<T>(bar: T, baz: number): T;
function foo<T>(bar: T, baz: boolean): T;
/**
 * @param bar
 * @param baz
 * @returns
 */
function foo<T>(bar: T, baz: number | boolean): T {
	return bar;
}

Environment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions