Typescript: Component declaration reference is not recognized by parser
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- react, typescript
- Lĩnh vực
- devtools
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện vấn đề trong playground của react-docgen với Language được đặt thành Typescript, sử dụng mẫu .tsx và gọi reactDocgen.parse() trên tham chiếu khai báo. Truy dấu điểm vào của parser đối với các khai báo .d.ts và so sánh kết quả với đầu ra mong đợi, trong đó Component2 được bao gồm cùng với mô tả, displayName, methods và props của nó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Many Typescript libraries publish types in declaration files (.d.ts) alongside their associated .js bundles. In .d.ts files generated through TS compilation, function types are often defined using declaration references, such as:
declare const MyComponent: React.FunctionComponent<ComponentProps>;
Currently declaration references are not recognized by reactDocgen.parse(). When react-docgen parses a .d.ts file with a single declaration reference, it emits an error: Error: No suitable component definition found..
Desired Behavior
The following code:
import * as React from 'react';
interface ComponentProps {
foo: string;
}
/**
* My component is so darn cool!
*/
const Component1: React.FunctionComponent<ComponentProps> = () => <div />;
/**
* Mine too!
*/
declare const Component2: React.FunctionComponent<ComponentProps>;
Results in the following output:
[
{
"description": "My component is so darn cool!",
"displayName": "Component1",
"methods": [],
"props": {
"foo": {
"required": true,
"tsType": {
"name": "string"
},
"description": ""
}
}
},
{
"description": "Mine too!",
"displayName": "Component2",
"methods": [],
"props": {
"foo": {
"required": true,
"tsType": {
"name": "string"
},
"description": ""
}
}
}
]
Actual Behavior
The same code results in the following output:
[
{
"description": "My component is so darn cool!",
"displayName": "Component1",
"methods": [],
"props": {
"foo": {
"required": true,
"tsType": {
"name": "string"
},
"description": ""
}
}
}
]
Steps to Reproduce
Paste the .tsx sample code from the "Expected Behavior" section into the react-docgen playground with Language set to Typescript.
- Ngôn ngữ chính
- TypeScript
- Star
- 3.8k
- Fork
- 316
- Merge trung bình
- 3 giờ 28 phút
- Pull request đã merge (30 ngày)
- 6
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.
Issue khác của reactjs/react-docgen
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
reactjs/react-docgen#1102 ·
-
Typescript Status Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
reactjs/react-docgen#1005 · 4 reaction ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
reactjs/react-docgen#997 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
reactjs/react-docgen#994 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
reactjs/react-docgen#982 · 2 bình luận ·
Tất cả issue của reactjs/react-docgen
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
bug v2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
modelcontextprotocol/inspector#2458 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
railmapgen/rmp-gallery#4068 ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
carbon-design-system/ibm-products#9907 ·