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

feat(remix-server-runtime): add "jump to definition" support to useActionData/useLoaderData/SerializeFrom #4689

Closed

Conversation

sachinraja
Copy link

@sachinraja sachinraja commented Nov 25, 2022

These changes are upstreamed from work I did for tRPC.

For data inferred from useLoaderData, properties do not have jump to definition. This is because serialize.ts uses key remapping which breaks jump to definition support for TS (see microsoft/TypeScript#47813). I changed it to use a different strategy for filtering that keeps jump to definition.

Testing Strategy: used the playground and attempted to jump to definition on a property from useLoaderData

Before this PR:

before.mp4

After this PR:

jump-to-definition.mp4

@changeset-bot
Copy link

changeset-bot bot commented Nov 25, 2022

⚠️ No Changeset found

Latest commit: 569d05b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Nov 25, 2022

Hi @sachinraja,

Welcome, and thank you for contributing to Remix!

Before we consider your pull request, we ask that you sign our Contributor License Agreement (CLA). We require this only once.

You may review the CLA and sign it by adding your name to contributors.yml.

Once the CLA is signed, the CLA Signed label will be added to the pull request.

If you have already signed the CLA and received this response in error, or if you have any questions, please contact us at hello@remix.run.

Thanks!

- The Remix team

@remix-cla-bot
Copy link
Contributor

remix-cla-bot bot commented Nov 25, 2022

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

Copy link
Member

@sergiodxa sergiodxa left a comment

Choose a reason for hiding this comment

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

This is incredible! 🤩

@MichaelDeBoey MichaelDeBoey changed the title jump to definition support for useLoaderData properties feat(remix-server-runtime: add "jump to definition" support to useActionData/useLoaderData Nov 25, 2022
@MichaelDeBoey MichaelDeBoey changed the title feat(remix-server-runtime: add "jump to definition" support to useActionData/useLoaderData feat(remix-server-runtime: add "jump to definition" support to useActionData/useLoaderData/SerializeFrom Nov 25, 2022
@MichaelDeBoey MichaelDeBoey changed the title feat(remix-server-runtime: add "jump to definition" support to useActionData/useLoaderData/SerializeFrom feat(remix-server-runtime): add "jump to definition" support to useActionData/useLoaderData/SerializeFrom Nov 25, 2022
Copy link
Member

@MichaelDeBoey MichaelDeBoey left a comment

Choose a reason for hiding this comment

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

Thanks @sachinraja, this is really awesome! 🤩

Since we want to move to type-fest's Jsonify type at some point in the future, you might want to add these changes there as well.

@tigerabrodi
Copy link

This is amazing!! 🔥 🙏
wp6229337

@pcattori
Copy link
Contributor

pcattori commented Dec 6, 2022

@sachinraja thanks for working on this! 🙏

I saw on your twitter that microsoft/TypeScript#51650 potentially address this as a TS fix rather than something we need to do in our own types within Remix. Am I interpreting that correctly?

@sachinraja
Copy link
Author

@pcattori Yes that PR could fix this. But I also implemented a more robust version of this fix in type-fest so I would recommend switching to the type-fest Jsonify type instead.

Then if the TypeScript PR goes through we can just change the type-fest type to a more performant one too.

@nexxeln
Copy link
Contributor

nexxeln commented Mar 2, 2023

Bumping this. Why hasn't this been merged yet? It's incredible

@Nsttt
Copy link

Nsttt commented Mar 2, 2023

Please, this one results on a very useful feature.

@MichaelDeBoey
Copy link
Member

@sachinraja Could you please rebase on latest dev, resolve conflicts & update with what you ended up pushing to type-fest?

@sachinraja
Copy link
Author

@MichaelDeBoey I don't think we can use the type-fest type because of SerializeDeferred, which handles Remix-specific behavior.

@MichaelDeBoey
Copy link
Member

@sachinraja I'm not talking about using type-fest, but rather copying over the things you did there instead
At a later stage, we can add the dependency if we want to.

@pcattori
Copy link
Contributor

Looks like microsoft/TypeScript#51650 got merged. Anyone want to look into whether its already released or when it will be released as part of TypeScript?

@Andarist
Copy link
Contributor

Andarist commented May 3, 2023

microsoft/TypeScript#51650 with microsoft/TypeScript#53207 should be a part of typescript@5.0.4 release. That can be confirmed by checking that this work belongs to the https://github.com/microsoft/TypeScript/commits/release-5.0

@MichaelDeBoey
Copy link
Member

@sachinraja Now that "jump to definition" is fixed, can the types be simplified again or did you extract some things for other reasons as well?

Would love to merge this as the changes you did for type-fest included some edge cases we don't cover (yet) as well 🙏

@pcattori
Copy link
Contributor

pcattori commented Jul 5, 2023

Closing this since TS 5.0.4 fixes it and we are already looking into swapping out our custom JSON serialize/deserialize types in favor of type-fest (#6642)

@pcattori pcattori closed this Jul 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants