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

internal: Test TypeScript 4.0, 4.1, 4.3 #2505

Merged
merged 3 commits into from
Mar 21, 2023
Merged

internal: Test TypeScript 4.0, 4.1, 4.3 #2505

merged 3 commits into from
Mar 21, 2023

Conversation

ntucker
Copy link
Collaborator

@ntucker ntucker commented Mar 19, 2023

Motivation

TS upgrade paths require libraries to support their old versions and new versions so they can first upgrade library, then TypeScript. This is in case the new TS introduces something that breaks in the library.

Also easier adoption for existing projects.

Solution

Generally we try to reduce as little functionality as possible, but when necessary we resort to looser types so it is at least compatible.

Core

  • Had to loosen parameters of EndpointUpdateFunction, because versions prior to 4.8 do not correctly produce types when dealing with generics.

Endpoint

Rest

  • Realized 4.1 is sufficient for our template literal inference. 4.0 can therefore be supported with less types.
    • Moved path template typing to 4.1, and loose typing to 4.0
  • Due to inability to generate specific types in 4.0, we loosen OptionsToFunction parameters...This is used to infer parameter types for .extend()
  • Produce a working but terribly typed hookifyResource so it at least doesn't crash in 4.0
  • Introduced the brilliant RequiredKeys utility which allows us to make urlParams optional if it contains no required members
  • Properly generate searchParams member in paginated endpoint so extends works correctly

CI

  • Add new simplified typescript module that has no other library requirements to use for checking 4.3 and older versions of typescript that don't work with antd or linaria
  • Add type validation for 4.0, 4.1, 4.3

@vercel
Copy link

vercel bot commented Mar 19, 2023

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

Name Status Preview Comments Updated
rest-hooks ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 21, 2023 at 5:21PM (UTC)

@ntucker ntucker force-pushed the morelegacytype branch 2 times, most recently from 7164818 to d349906 Compare March 19, 2023 22:59
@ntucker ntucker force-pushed the morelegacytype branch 2 times, most recently from 9462f89 to db44b0f Compare March 21, 2023 01:31
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.

None yet

1 participant