Fix Tone.js types by upgrading TypeScript and tslib - #68
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
typescript@3.7.3predatesimport typesyntax (added in TS 3.8), which Tone v15's.d.tsfiles use throughout. TS 3.7.3 can't parse those declaration files at all, soimport * as Tone from 'tone'silently resolved toany— that's whyTone.Sequenceand everything under it (e.g. the sequencer callback'stime/stepparams inTrack.tsx) showed no types/autocomplete.typescript^3.7.3→^4.9.5.tslib^1.14.1→^2.8.1— TS 4.9 emits the__spreadArrayhelper, which only exists in tslib 2.x.src/lib/utils.ts: add a missingreturn true— once type-checking actually completes instead of aborting on unparseable Tone types,noImplicitReturns(already enabled in tsconfig) catches this real gap.Verification
tsc --noEmitpasses clean (previously failed outright with dozens of parse errors insidenode_modules/tone/**/*.d.ts)Tone.Sequence's callback params now carry real inferred types (verified via a throwaway@ts-expect-errorcheck — previously that would've errored "unused directive" since everything wasany)tsdx lint,tsdx test(14 tests), andtsdx buildall pass