microsoft / microsoft/TypeScript
`getJSDocTags` detects decorators inside code blocks as JSDoc tags
Đang mở
Chưa có ai nhận issue này.
Awaiting More Feedback
Suggestion
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.4k
- Merge trung bình
- 1 ngày 19 giờ
- Pull request đã merge (30 ngày)
- 117
Mô tả
🔎 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
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu với API getJSDocTags và tái hiện hành vi bằng ví dụ StackBlitz trong issue. Theo dõi cách chú thích JSDoc được phân tích xung quanh fenced code block, sau đó xác minh rằng chỉ tag usageNotes được trích xuất và phần văn bản giống decorator bị bỏ qua.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- compilers
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100