Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Playground static-assets example throws ReferenceError on Submit because message is undefined, hidden by another example's ambient global

Chiusa Adatta ai principianti
#1,805 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
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend, testing

Direzione di ricerca

Inizia da apps/playground/src/instruments/examples/interactive/Interactive-With-Static-Assets/index.ts e dal relativo fragment.html; confronta il gestore Submit con la validationSchema dell’esempio. Leggi anche Interactive-With-Legacy-Script/legacy.d.ts per capire perché il controllo dei tipi non rileva l’identificatore non definito. Aggiungi un controllo end-to-end in testing/src/specs/playground.spec.ts; il lavoro è concluso quando l’invio di questo esempio va a buon fine con un messaggio valido.

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

Descrizione

Area: Playground Bug Difficulty: Low Good First Issue Priority: Low

The playground's "Interactive Instrument with Static Assets" example can never be completed. Its Submit handler calls done({ message }), but nothing in the instrument defines message, so clicking Submit throws ReferenceError: message is not defined and done is never called. Type-checking does not catch it, because a different example, Interactive-With-Legacy-Script/legacy.d.ts, declares declare let message: 'hello' as an ambient global. That declaration is in scope for every file under apps/playground/src, so tsc (and pnpm lint) accept the undefined identifier.

Where

apps/playground/src/instruments/examples/interactive/Interactive-With-Static-Assets/index.ts:18-23:

render(done) {
  const button = document.getElementById('submit-btn')!;
  button.addEventListener('click', () => {
    done({ message });
  });
},

The global that hides it, apps/playground/src/instruments/examples/interactive/Interactive-With-Legacy-Script/legacy.d.ts:1:

declare let message: 'hello';

fragment.html has no element with id="message" either, so no named-element global exists at runtime.

Reproduce

  1. Open the playground and select Examples → Interactive Instrument with Static Assets.
  2. Click Submit in the preview.

Actual: the browser console shows ReferenceError: message is not defined, and the instrument never completes.
Expected: the instrument completes with a message string that satisfies its validationSchema.

Tests

The playground's vitest project only covers pure modules, so the e2e test is the guard: in testing/src/specs/playground.spec.ts, select this example, click Submit in the preview frame, and assert that the instrument reaches its completed state.

Suggested fix

Pass a literal, e.g. done({ message: 'Hello' }). Then scope the legacy example's ambient declaration so it cannot mask undefined identifiers in other examples, for example by declaring it as window.message (declare global { interface Window { message: 'hello' } }) and reading it as window.message in that example.

Lingua principale
TypeScript
Stelle
119
Fork
19
Merge medio
4g 11h
PR unite (30g)
35

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 DouglasNeuroInformatics/OpenDataCapture

Tutte le issue di DouglasNeuroInformatics/OpenDataCapture

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.