JSDoc.getTags()[0].getTagName() fails on @template tag
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
**Describe the bug**
typescript version: 3.7.4
ts-morph version: 6.0.2
Here's an odd one! I am unable to call `getTagName()` on JSDoc tags if they are `@template` tags. Oddly, I have a number of other tag names in my codebase, several of which are nonstandard, and yet `@template` is the only offender.
**To Reproduce**
```ts
import { Project, SyntaxKind, ts } from 'ts-morph';
console.log(ts.version); // 3.7.4
const project = new Project();
const file = project.createSourceFile(
'src/tmp.ts',
[
'/** @template Thing this is a thing */',
'const printThing = (thing: Thing): Thing => {',
' console.log(thing);',
' return thing;',
'};',
].join('\n'),
);
// Print all tag names
file.getFirstDescendantByKindOrThrow(SyntaxKind.VariableStatement)
.getJsDocs()
.forEach(jsDoc => {
jsDoc.getTags().forEach(tag => {
console.log(tag.getTagName()); // TypeError: tag.getTagName is not a function
});
});
```
**Expected behavior**
Console prints `@template`.
**Actual behavior**
`TypeError: tag.getTagName is not a function`
In my case I am able to work around the issue, but it is a bit of a nuisance (and a curiosity!)
Contributor guide
Assessment
This issue has not been assessed yet.