Skip to content

sound: fix lint errors on conductor-migration#818

Merged
Akshay-2007-1 merged 2 commits into
conductor-migrationfrom
fix/sound-lint-and-followups
Jul 24, 2026
Merged

sound: fix lint errors on conductor-migration#818
Akshay-2007-1 merged 2 commits into
conductor-migrationfrom
fix/sound-lint-and-followups

Conversation

@Akshay-2007-1

@Akshay-2007-1 Akshay-2007-1 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Fixes both problems blocking the conductor-migration deploy after #796 merged.

1. Lint errors (@martin-henz's report)

@sourceacademy/throw-runtime-error doesn't recognize EvaluatorParameterTypeError as assignable to RuntimeSourceError - same known gap already worked around in midi. 6 call sites across functions.ts/index.ts hit this.

Separately, conductorToSound's invalid() helper was throwing a plain Error, not a Conductor error type at all - a real bug, not just a lint gap, since it would bypass proper student-facing error formatting.

What changed:

  • Added the same eslint-disable-next-line @sourceacademy/throw-runtime-error + explanatory comment midi already uses, at each of the 6 EvaluatorParameterTypeError call sites.
  • Fixed invalid() to throw EvaluatorRuntimeError instead of a plain Error, and inlined the three call sites (the indirection through a helper function was itself what kept the linter from recognizing a type it accepts fine when thrown directly).
  • Left the constructor's soundChannel wiring guard as a plain Error with a disable comment - a genuine internal precondition (Conductor host failed to provide the channel), never reachable from student code.
  • Fixed two @stylistic/member-delimiter-style warnings in recording.test.ts.

Verified clean: lint, tsc, all 64 tests pass.

2. Docs build failure (twoslash type errors)

#796 removed AudioPlayed/SoundModuleState entirely (the old js-slang moduleContexts.sound.state pattern doesn't apply to Conductor-based modules) and reshaped Sound from a Pair to {leftWave, rightWave, duration}. Several doc pages' embedded, type-checked code samples still referenced the old shapes, failing the docs build's twoslash validation:

  • 2-bundle/4-conventions/3-errors.md: make_sound sample used pair() from js-slang/dist/stdlib/list against the old Sound type - rewritten to return the real {leftWave, rightWave, duration} shape.
  • 5-advanced/context.md, 3-tabs/1-overview.md, 3-tabs/3-editing.md: all three used sound as their example bundle for the general js-slang module context / getModuleState pattern, referencing AudioPlayed/SoundModuleState which no longer exist at all. Swapped to curve, which still legitimately uses this pattern (sound moved to Conductor's own channel-based state instead) - reused curve's actual CurveModuleState/drawnCurves shape and the real Curve tab's own getModuleState usage as the reference.

Verified the two rewritten samples against a real tsc --strict run (not just eyeballing) - both type-check clean.

4-testing/4-unit/3-mock.md and 2-bundle/1-overview/1-overview.md also reference bundle-sound but only via imports/calls that stay valid regardless of Sound's internal shape (no destructuring assuming the old pair shape) - left as-is, not build-blocking, though mock.md's AudioContext example is now semantically stale (play() no longer touches AudioContext directly) and could use a follow-up pass.

…Error

@sourceacademy/throw-runtime-error doesn't yet recognize
EvaluatorParameterTypeError as assignable to RuntimeSourceError (same known
gap already worked around in midi) - added the same eslint-disable +
explanatory comment at each of the 6 call sites in functions.ts/index.ts.

conductorToSound's invalid() helper was throwing a plain Error, not a
Conductor error type at all - a real bug, not just a lint gap, since it
would bypass proper student-facing error formatting. Fixed to
EvaluatorRuntimeError; inlined the three call sites since the indirection
through a helper function was itself what kept the linter from recognizing
a type it accepts fine when thrown directly.

The constructor's soundChannel wiring guard is left as a plain Error with a
disable comment - a genuine internal precondition (Conductor host failed to
provide the channel), never reachable from student code.

Also fixed two @stylistic/member-delimiter-style warnings in
recording.test.ts (semicolons vs commas in an inline type).
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

#796's Conductor migration removed AudioPlayed/SoundModuleState entirely
(the old js-slang moduleContexts.sound.state pattern doesn't apply to
Conductor-based modules) and reshaped Sound from a Pair to
{leftWave, rightWave, duration} - several doc pages' embedded, type-checked
code samples still referenced the old shapes, failing the docs build's
twoslash validation:

- 2-bundle/4-conventions/3-errors.md: make_sound sample used pair() from
  js-slang/dist/stdlib/list against the old Sound type - rewritten to
  return the real {leftWave, rightWave, duration} shape.
- 5-advanced/context.md, 3-tabs/1-overview.md, 3-tabs/3-editing.md: all
  three used sound as their example bundle for the general js-slang module
  context / getModuleState pattern, referencing AudioPlayed/SoundModuleState
  which no longer exist at all. Swapped to curve, which still legitimately
  uses this pattern (sound moved to Conductor's own channel-based state
  instead) - reused curve's actual CurveModuleState/drawnCurves shape and
  the real Curve tab's own getModuleState usage as the reference.

Verified the two rewritten make_sound/context samples against a real tsc
--strict run (not just eyeballing) - both type-check clean.

4-testing/4-unit/3-mock.md and 2-bundle/1-overview/1-overview.md also
reference bundle-sound but only via imports/calls that stay valid regardless
of Sound's internal shape (no destructuring assuming the old pair shape) -
left as-is, not build-blocking, though mock.md's AudioContext example is now
semantically stale (play() no longer touches AudioContext directly) and
could use a follow-up pass.
@Akshay-2007-1
Akshay-2007-1 merged commit 9a02a7e into conductor-migration Jul 24, 2026
@Akshay-2007-1
Akshay-2007-1 deleted the fix/sound-lint-and-followups branch July 24, 2026 12:37
Akshay-2007-1 added a commit that referenced this pull request Jul 24, 2026
…es (#819)

CurveDrawn is imported into curve/types.ts from ./curves_webgl but never
re-exported from it - only CurveModuleState (which uses CurveDrawn as part
of its drawnCurves field type) is actually exported from
@sourceacademy/bundle-curve/types. #818's context.md fix imported CurveDrawn
directly, which doesn't exist at that import path (TS2459), breaking the
docs build again. Fixed by deriving the element type via
CurveModuleState['drawnCurves'] instead - the same pattern already used
correctly in this PR's other two fixed files (3-tabs/1-overview.md,
3-tabs/3-editing.md), just missed here.

Verified against a real tsc --strict run this time, not just eyeballing -
all imports across all 4 previously-touched doc pages checked against their
actual compiled .d.ts exports, not just what's declared in bundle source.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant