Skip to content

Fix Tone.js types by upgrading TypeScript and tslib - #68

Merged
unkleho merged 2 commits into
mainfrom
fix-tone-types
Aug 20, 2026
Merged

Fix Tone.js types by upgrading TypeScript and tslib#68
unkleho merged 2 commits into
mainfrom
fix-tone-types

Conversation

@unkleho

@unkleho unkleho commented Aug 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • typescript@3.7.3 predates import type syntax (added in TS 3.8), which Tone v15's .d.ts files use throughout. TS 3.7.3 can't parse those declaration files at all, so import * as Tone from 'tone' silently resolved to any — that's why Tone.Sequence and everything under it (e.g. the sequencer callback's time/step params in Track.tsx) showed no types/autocomplete.
  • Bump typescript ^3.7.3^4.9.5.
  • Bump tslib ^1.14.1^2.8.1 — TS 4.9 emits the __spreadArray helper, which only exists in tslib 2.x.
  • src/lib/utils.ts: add a missing return true — once type-checking actually completes instead of aborting on unparseable Tone types, noImplicitReturns (already enabled in tsconfig) catches this real gap.

Verification

  • tsc --noEmit passes clean (previously failed outright with dozens of parse errors inside node_modules/tone/**/*.d.ts)
  • Confirmed Tone.Sequence's callback params now carry real inferred types (verified via a throwaway @ts-expect-error check — previously that would've errored "unused directive" since everything was any)
  • tsdx lint, tsdx test (14 tests), and tsdx build all pass

typescript@3.7.3 predates the `import type` syntax (added in 3.8)
that Tone v15's .d.ts files use, so `tsc` couldn't parse them at
all — `import * as Tone from 'tone'` silently fell back to `any`,
which is why Tone.Sequence and friends showed no types/autocomplete.

- typescript ^3.7.3 -> ^4.9.5
- tslib ^1.14.1 -> ^2.8.1, since 4.9 emits the `__spreadArray` helper
  that only exists in tslib 2.x
- utils.ts: add a missing return path now caught by noImplicitReturns
  once type-checking actually runs to completion

Verified `tsc --noEmit`, `tsdx lint`, `tsdx test`, and `tsdx build`
all pass, and that Tone.Sequence's callback params now carry real
inferred types instead of implicit any.
@unkleho
unkleho merged commit 5e2f8ff into main Aug 20, 2026
1 check passed
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