Next.js wizard creates untyped Pages Router files that fail strict type checking

Đang mở Phù hợp với người mới
#1,396 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
next.js, typescript
Lĩnh vực
tooling

Hướng nghiên cứu

Mở src/nextjs/templates.ts và đọc getSentryDefaultUnderscoreErrorPage và getSentryExamplePagesDirApiRoute; đây là hai bộ sinh mã xuất ra các tham số không có kiểu props, contextData, _req và res. Chỉ thêm kiểu tham số TypeScript vào các biến thể template TypeScript, và giữ đầu ra JavaScript không có kiểu như #1014 yêu cầu. Sau đó chạy các bài kiểm tra template nextjs hiện có và sinh các tệp vào một dự án pages TS strict để xác nhận next build kiểm tra kiểu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Environment

@sentry/wizard master (b262ed0, 9.1.0 plus one commit), Next.js integration, Next.js 16.4.6, TypeScript 5 with strict: true. Reproduced with the wizard's templates directly, not a full wizard run.

Steps to Reproduce
  1. Have a TypeScript Next.js project with a pages directory and no custom _error page.
  2. Run npx @sentry/wizard -i nextjs and create the example page.
  3. Run next build.
Expected Result

The build passes.

Actual Result

The generated files contain untyped parameters and the type check fails:

pages/_error.tsx(4,31): error TS7006: Parameter 'props' implicitly has an 'any' type.
pages/_error.tsx(8,47): error TS7006: Parameter 'contextData' implicitly has an 'any' type.
pages/api/sentry-example-api.ts(11,33): error TS7006: Parameter '_req' implicitly has an 'any' type.
pages/api/sentry-example-api.ts(11,39): error TS7006: Parameter 'res' implicitly has an 'any' type.
Failed to type check.

See getSentryDefaultUnderscoreErrorPage and getSentryExamplePagesDirApiRoute in src/nextjs/templates.ts. The JavaScript variants need to stay untyped (see #1014).

Ngôn ngữ chính
TypeScript
Star
297
Fork
88
Merge trung bình
5 giờ 29 phút
Pull request đã merge (30 ngày)
5

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của getsentry/sentry-wizard

Tất cả issue của getsentry/sentry-wizard

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.