Skip to content

Commit 374daac

Browse files
committed
fix(no-undefined-types): ensure parsing takes into account template names with defaults
1 parent 53e4174 commit 374daac

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -10367,6 +10367,19 @@ const a = 'string';
1036710367
*/
1036810368
const a = new Todo();
1036910369
// Settings: {"jsdoc":{"mode":"typescript"}}
10370+
10371+
/**
10372+
* @template A, [B=SomeDefault]
10373+
*/
10374+
class Foo {
10375+
/**
10376+
* @param {A} baz
10377+
* @return {B}
10378+
*/
10379+
bar (baz) {
10380+
}
10381+
}
10382+
// Settings: {"jsdoc":{"mode":"typescript"}}
1037010383
````
1037110384

1037210385

src/jsdocUtils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1291,7 +1291,7 @@ const parseClosureTemplateTag = (tag) => {
12911291
return tag.name
12921292
.split(',')
12931293
.map((type) => {
1294-
return type.trim();
1294+
return type.trim().replace(/^\[(?<name>.*?)=.*\]$/u, '$<name>');
12951295
});
12961296
};
12971297

test/rules/assertions/noUndefinedTypes.js

+20
Original file line numberDiff line numberDiff line change
@@ -1258,5 +1258,25 @@ export default {
12581258
},
12591259
},
12601260
},
1261+
{
1262+
code: `
1263+
/**
1264+
* @template A, [B=SomeDefault]
1265+
*/
1266+
class Foo {
1267+
/**
1268+
* @param {A} baz
1269+
* @return {B}
1270+
*/
1271+
bar (baz) {
1272+
}
1273+
}
1274+
`,
1275+
settings: {
1276+
jsdoc: {
1277+
mode: 'typescript',
1278+
},
1279+
},
1280+
},
12611281
],
12621282
};

0 commit comments

Comments
 (0)