From 6989699d4305809eca3ada704ad7329e3d178c81 Mon Sep 17 00:00:00 2001 From: Brett Zamir Date: Sun, 18 Jul 2021 15:48:55 +0800 Subject: [PATCH] fix(`valid-types`): allow and require types on `@extends` for TypeScript as used in docs (and not name) --- README.md | 6 ++++++ src/getDefaultTagStructureForMode.js | 6 +++--- test/rules/assertions/validTypes.js | 14 ++++++++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 15ac135a2..787586612 100644 --- a/README.md +++ b/README.md @@ -20538,6 +20538,12 @@ type ComplicatedType = never * prop: number * }} MyOptions */ + +/** + * @extends {SomeType} + */ +class quux {} +// Settings: {"jsdoc":{"mode":"typescript"}} ```` diff --git a/src/getDefaultTagStructureForMode.js b/src/getDefaultTagStructureForMode.js index 7aba7ad68..e440366fb 100644 --- a/src/getDefaultTagStructureForMode.js +++ b/src/getDefaultTagStructureForMode.js @@ -163,12 +163,12 @@ const getDefaultTagStructureForMode = (mode) => { ['nameContents', 'namepath-referencing'], // Does not show curly brackets in either the signature or examples - ['typeAllowed', isClosureOrPermissive], + ['typeAllowed', isTypescriptOrClosure || isPermissive], - ['nameRequired', isJsdocOrTypescript], + ['nameRequired', isJsdoc], // "namepath" - ['typeOrNameRequired', isClosureOrPermissive], + ['typeOrNameRequired', isTypescriptOrClosure || isPermissive], ])], ['external', new Map([ diff --git a/test/rules/assertions/validTypes.js b/test/rules/assertions/validTypes.js index 4f9012ce8..c3a97a8ca 100644 --- a/test/rules/assertions/validTypes.js +++ b/test/rules/assertions/validTypes.js @@ -1264,5 +1264,19 @@ export default { sourceType: 'module', }, }, + { + code: ` + /** + * @extends {SomeType} + */ + class quux {} + + `, + settings: { + jsdoc: { + mode: 'typescript', + }, + }, + }, ], };