microsoft / microsoft/TypeScript
`getJSDocTags` detects decorators inside code blocks as JSDoc tags
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
🔎 Search Terms
- jsdoc
getJSDocTags- decorators
🕗 Version & Regression Information
This is faulty behavior
⏯ Playground Link
https://stackblitz.com/edit/gettextofjsdoccomment-d88fzj?file=main.ts,package.json
💻 Code
import ts from 'typescript';
const filename = 'example.ts';
const code = `
/**
*
* @usageNotes
*
* Use \`afterNextRender\` to read or write the DOM once,
* for example to initialize a non-Angular library.
*
* ### Example
* \`\`\`ts
* @Component({
* selector: 'my-chart-cmp',
* template: \`<div #chart>{{ ... }}</div>\`,
* })
* export class MyChartCmp {
* @ViewChild('chart') chartRef: ElementRef;
* chart: MyChart|null;
*
* constructor() {
*
* }
* }
* \`\`\`
*/
class Foo {};
`;
const sourceFile = ts.createSourceFile(
filename,
code,
ts.ScriptTarget.ESNext,
true
);
const visitNode = (node: ts.Node) => {
ts.forEachChild(node, visitNode);
const tags = ts.getJSDocTags(node);
if (tags.length) {
tags.forEach((tag) => {
const comment = tag.comment!.slice(1) as any;
console.log(
'> ',
tag.tagName.getText(),
' | ',
ts.getTextOfJSDocComment(comment)
);
});
}
};
ts.forEachChild(sourceFile, visitNode);
🙁 Actual behavior
We get 2 distinct tags:
> usageNotes | se `afterNextRender` to read or write the DOM once,
for example to initialize a non-Angular library.
### Example
```ts
> Component | {
selector: 'my-chart-cmp',
template: `<div #chart>{{ ... }}</div>`,
})
export class MyChartCmp {
> ViewChild | 'chart') chartRef: ElementRef;
chart: MyChart|null;
constructor() {
}
}
🙂 Expected behavior
Only one tag should be extracted : usagenotes
Additional information about the issue
No response
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con l’API getJSDocTags e riproduci il comportamento usando l’esempio StackBlitz nell’issue. Traccia il modo in cui il commento JSDoc viene analizzato intorno al fenced code block, quindi verifica che venga estratto solo il tag usageNotes e che il testo simile a un decoratore venga ignorato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100