Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile errors #455

Merged
merged 1 commit into from
Feb 5, 2025
Merged

Conversation

shawwn
Copy link
Collaborator

@shawwn shawwn commented Feb 1, 2025

I did a fresh checkout of Signal just now. To my surprise, npm run build followed by npm start ended up showing two compile errors. When I opened it in Webstorm the IDE confirmed there were problems.

Problem 1

image
            <SelectBox
              items={categoryOptions}
              selectedValue={selectedCategoryId} // Error TS2322: Type 'number' is not assignable to type 'object'.
              onChange={(i) =>
                onChange({
                  programNumber: i * 8, // Choose the first instrument of the category
                  isRhythmTrack,
                })
              }
            />

Since selectedCategoryId is a number, then SelectBox<T> becomes SelectBox<number>. However, SelectBox currently requires SelectBox<T extends object>, causing an error because number doesn't extend object.

Solution 1

Removed extends object

Problem 2

image
          dragSelectionGesture.onMouseDown(
            ev.nativeEvent,
            hitEventId,
            local,
            controlTransform,
            eventType, // Error TS2554: Expected 4 arguments, but got 5.
          )

The above onMouseDown method only takes 4 arguments:

    onMouseDown<T extends ControllerEvent | PitchBendEvent>(
      e: MouseEvent,
      hitEventId: number,
      startPoint: Point,
      transform: ControlCoordTransform,
    ) {

Solution 2

Removed eventType, from the list of args passed to onMouseDown


Looking at the git blame, those lines of code haven't changed in a very long time (since 2022), so I wonder why the compiler is suddenly detecting these errors. Were there recent changes to tsconfig? Or could it be because you made eslint changes? Either way, it's nice that these were caught. (Maybe they were warnings before?)

Copy link

vercel bot commented Feb 1, 2025

@shawwn is attempting to deploy a commit to the Ryohei Kameyama's projects Team on Vercel.

A member of the Team first needs to authorize it.

@shawwn
Copy link
Collaborator Author

shawwn commented Feb 1, 2025

It looks like Problem 1 was introduced in 0fa2c0d:
image

As for Problem 2, I have no idea, because SelectBox has been defined as SelectBox<T extends object> for two years now, and the code that was causing the error has also been there for two years, so it seems like this error should have showed up a long time ago.

@ryohey
Copy link
Owner

ryohey commented Feb 2, 2025

The version of typescript used may be different. npm install and try npm run build again. VSCode is recommended as the development environment.

@shawwn
Copy link
Collaborator Author

shawwn commented Feb 4, 2025

Well, even if the version is different, this PR still fixes two legitimate problems. A different version of typescript missing those problems seems unrelated.

@ryohey
Copy link
Owner

ryohey commented Feb 5, 2025

okay I reproduced that errors. my dev environment was something wrong.
Thank you for fixing it!

Copy link

vercel bot commented Feb 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
signal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 5, 2025 5:24am

@ryohey ryohey self-requested a review February 5, 2025 05:22
@ryohey ryohey merged commit acdc421 into ryohey:main Feb 5, 2025
3 checks 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.

2 participants