Skip to content

Commit 7461e01

Browse files
committed
fix(require-jsdoc): ensure children of TS type reference and parameter instantiation can be exports; fixes #1186
1 parent 3697321 commit 7461e01

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/exportParser.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,8 @@ const canExportChildrenType = new Set([
741741
'TSInterfaceDeclaration',
742742
'TSTypeLiteral',
743743
'TSTypeAliasDeclaration',
744+
'TSTypeParameterInstantiation',
745+
'TSTypeReference',
744746
'ClassDeclaration',
745747
'ClassBody',
746748
'ClassDefinition',

test/rules/assertions/requireJsdoc.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4191,6 +4191,58 @@ function quux (foo) {
41914191
}
41924192
},
41934193
},
4194+
{
4195+
code: `
4196+
/**
4197+
* Command options for the login command
4198+
*/
4199+
export type LoginOptions = CmdOptions<{
4200+
username?: string;
4201+
password?: string;
4202+
}>;
4203+
`,
4204+
errors: [
4205+
{
4206+
line: 6,
4207+
message: 'Missing JSDoc comment.',
4208+
},
4209+
{
4210+
line: 7,
4211+
message: 'Missing JSDoc comment.',
4212+
},
4213+
],
4214+
options: [
4215+
{
4216+
publicOnly: {
4217+
ancestorsOnly: true,
4218+
},
4219+
contexts: [
4220+
'TSTypeAliasDeclaration',
4221+
'TSInterfaceDeclaration',
4222+
'TSMethodSignature',
4223+
'TSPropertySignature',
4224+
],
4225+
},
4226+
],
4227+
output: `
4228+
/**
4229+
* Command options for the login command
4230+
*/
4231+
export type LoginOptions = CmdOptions<{
4232+
/**
4233+
*
4234+
*/
4235+
username?: string;
4236+
/**
4237+
*
4238+
*/
4239+
password?: string;
4240+
}>;
4241+
`,
4242+
languageOptions: {
4243+
parser: typescriptEslintParser,
4244+
},
4245+
},
41944246
],
41954247
valid: [
41964248
{

0 commit comments

Comments
 (0)