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

Upgrade to TypeScript 5.6 #28

Merged
merged 2 commits into from
Oct 14, 2024
Merged

Conversation

jthemphill
Copy link

I'm pretty sure the new version of TypeScript is pointing out that we're passing a Partial<ScriptState> to a function that expects a ScriptState. This PR just changes the function to expect a Partial<ScriptState> instead.

package.json Show resolved Hide resolved
Comment on lines 90 to 91
setHistory: Dispatch<SetStateAction<History<Partial<T>>>>,
a: PureHistoryAction<Partial<T>>,
Copy link
Author

@jthemphill jthemphill Oct 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also remove the generic and make it

export function pureHistoryApply(
  setHistory: SetHistory,
  a: PureHistoryAction<Partial<ScriptState>>,
) { /* ... */ }

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go with that. In principle having it generic is nice but there's only type of history in this project so let's just have it reflect that. I'd prefer having it be monomorphic than generic-but-not-as-generic-as-possible.

@tchajed
Copy link
Owner

tchajed commented Oct 14, 2024

Thanks for looking into this, this fix really helped me understand what's going on. I checked and the actual issue isn't with pureHistoryApply (which does take an arbitrary history state type T) but with type inference at the call site, which incorrectly infers T = ScriptState instead of T = Partial<ScriptState> (seemingly a regression).

Copy link
Owner

@tchajed tchajed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for fixing this!

@tchajed tchajed merged commit 9271309 into tchajed:main Oct 14, 2024
2 checks passed
@jthemphill jthemphill deleted the jthemphill/ts-5.6 branch October 14, 2024 20:00
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.

Fix typechecking in TypeScript 5.6.3
2 participants