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

オープン 初心者向け
#1,396 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
next.js, typescript
領域
tooling

調査の方向性

src/nextjs/templates.ts を開き、getSentryDefaultUnderscoreErrorPage と getSentryExamplePagesDirApiRoute を読んでください。この2つは、型のない props、contextData、_req、res のパラメーターを出力するジェネレーターです。TypeScript テンプレートのバリアントにのみ TypeScript のパラメーター型を追加し、#1014 の要件どおり JavaScript の出力は型なしのままにしてください。その後、既存の nextjs テンプレートのテストを実行し、strict な TS の pages プロジェクトにファイルを生成して、next build が型チェックを行うことを確認してください。

索引モデルが issue の本文から書いたものです。

説明

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).

主要言語
TypeScript
スター
297
フォーク
88
平均マージ
5時間 29分
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

getsentry/sentry-wizard のほかの issue

getsentry/sentry-wizard の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。