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

Aperta Adatta ai principianti
#1,396 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
next.js, typescript
Ambito
tooling

Direzione di ricerca

Apri src/nextjs/templates.ts e leggi getSentryDefaultUnderscoreErrorPage e getSentryExamplePagesDirApiRoute; sono i due generatori che emettono i parametri non tipizzati props, contextData, _req e res. Aggiungi i tipi dei parametri TypeScript solo alle varianti di template TypeScript, lasciando l'output JavaScript non tipizzato come richiesto da #1014, poi esegui i test esistenti dei template nextjs e genera i file in un progetto pages TS strict per verificare che next build controlli i tipi.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

Lingua principale
TypeScript
Stelle
297
Fork
88
Merge medio
5h 29m
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di getsentry/sentry-wizard

Tutte le issue di getsentry/sentry-wizard

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.