Для JSDo c @template
внутри фигурных скобок {...}
есть ограничение , а имя переменной шаблона следует ставить после фигурных скобок. Таким образом, правильный синтаксис должен быть:
/**
* Wraps a styled component to supply default props
* @template {{ defaultProps?: Partial<TDefaults> }} T - Component type
* @template {any} TDefaults - Default props
* @param {T} component - Our styled component object
* @param {TDefaults} defaultProps - The object's default props
* @returns the styled component with default props applied
*/
export function withDefault<T extends { defaultProps?: Partial<TDefaults> }, TDefaults>(component: T, defaultProps: TDefaults): T & { defaultProps: TDefaults } {
// eslint-disable-next-line no-param-reassign
component.defaultProps = defaultProps;
// Cast to any necessary as we can't infer styled component type
return component as any;
}
Вам также нужно установить опцию eslint settings.jsdoc.mode
в typescript
в соответствии с , это сделать c подавить ошибку.