JSDoc with @extends, type parameter and member expression gives wrong dts output
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, typescript
- Lĩnh vực
- compilers
Hướng nghiên cứu
Bắt đầu với reproducer được liên kết bằng cách checkout issue-typescript-missing-type-param, chạy npm install và npm run build, sau đó kiểm tra dist/index.d.ts. Truy vết đường dẫn phát sinh khai báo cho một member expression JSDoc @extends; hoàn tất khi mệnh đề extends được sinh ra vẫn giữ đối số kiểu T và khai báo được xác thực.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🔎 Search Terms
jsdoc type parameter generics extends superclass template
🕗 Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about JSDoc type parameters with
@extends
I tried with TypeScript 5.0.0, 5.6.2, and 5.7.0-dev.20241001.
⏯ Minimal repro link
I needed more than one file to reproduce, which I can't do on the playground. Here's a simple reproducer:
https://github.com/blutorange/issue-repro/tree/issue-typescript-missing-type-param
git clone https://github.com/blutorange/issue-repro
cd issue-repro
git checkout issue-typescript-missing-type-param
npm install
npm run build
Then open dist/index.d.ts.
💻 Code
/**
* @template {0|1|2} T
* @extends {Scope.sub.Box<T>}
*/
export class MyComponent extends Scope.sub.Box {
more() {
return "foo";
}
}
🙁 Actual behavior
The class in the extends clause is missing the type parameter. This is a compile error when you validate the .d.ts file.
declare const MyComponent_base: typeof import("./header.js").Box;
/**
* @template {0|1|2} T
* @extends {Scope.sub.Box<T>}
*/
export class MyComponent<T extends 0 | 1 | 2> extends MyComponent_base {
constructor();
more(): string;
}
export {};
🙂 Expected behavior
TypeScript should include the type parameter in the extends clause.
declare const MyComponent_base: typeof import("./header.js").Box;
/**
* @template {0|1|2} T
* @extends {Scope.sub.Box<T>}
*/
export class MyComponent<T extends 0 | 1 | 2> extends MyComponent_base<T> {
constructor();
more(): string;
}
export {};
Additional information about the issue
Only seems to happen when the extends clause is a member expression where TS generate an intermediate declare const ....
Fyi, I came across this issue while investigating how to setup a project for generating type declarations from js files for primefaces/primefaces#12500
- 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
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 microsoft/TypeScript
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
microsoft/TypeScript#64322 · 2 bình luận · 1 reaction · 2 người được giao ·
-
Possible Improvement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/TypeScript#64278 · 1 bình luận · 1 reaction ·
-
Docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
microsoft/TypeScript#64118 · 1 bình luận ·
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
microsoft/TypeScript#64094 ·
-
Docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
microsoft/TypeScript#63959 · 5 bình luận ·
Tất cả issue của microsoft/TypeScript
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
milvus-io/birdwatcher#545 ·
-
kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
kubernetes-sigs/prow#953 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
caddyserver/caddy#8046 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
jaegertracing/jaeger#9588 ·