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(core): sync @type/xxx packages #138

Open
kevinxh opened this issue Jun 5, 2023 · 5 comments
Open

feat(core): sync @type/xxx packages #138

kevinxh opened this issue Jun 5, 2023 · 5 comments

Comments

@kevinxh
Copy link

kevinxh commented Jun 5, 2023

Description

It would be nice if syncpack could sync the @type/xxx typescript declaration packages.

For example, we use syncpack fix-mismatches and upgrade one of our deps jsonwebtoken, but the types package @types/jsonwebtoken is left at older version.

Suggested Solution

Help Needed

@JamieMason
Copy link
Owner

Thanks @kevinxh, it's a good idea. The closest thing today is https://jamiemason.github.io/syncpack/config/version-groups/pinned#pinversion-string but that's quite manual. I'll have a think how best to do this, some kind of aliasing feature or something.

@JamieMason
Copy link
Owner

JamieMason commented Jun 25, 2023

Opening this up to people for ideas on a nice way to handle this

  • it doesn't fit well with how minimatch is used in dependencies.
  • it probably wouldn't work as a new type of version group, because that would prevent you from applying other rules to any packages which also have types packages.
  • it might work as a new option on version groups, but it wouldn't make sense for every kind of version group.
  • maybe it could be a global setting, but someone would probably need to undo it in some version group somewhere anyway.
  • ...some other way?

@mctrafik
Copy link

mctrafik commented Dec 7, 2023

I'm new to syncpack. I got here trying to figure out why this didn't work:

 {
      label: 'Ensure react is all same version',
      packages: ['**'],
      dependencies: ['react', 'react-dom', '@types/react', '@types/react-dom'],
      dependencyTypes: ['!peer'],
      policy: 'sameRange',
    },

So maybe similar syntax since that's how it reads.

@JamieMason
Copy link
Owner

JamieMason commented Dec 7, 2023

I think I see what you're trying to do there @mctrafik, I think this is close to the pinVersion approach I was alluding to above. So to manually force those 4 packages to have the exact same version you could change that slightly to:

{
  "label": "Ensure react is all same version",
  "packages": ["**"],
  "dependencies": ["react", "react-dom", "@types/react", "@types/react-dom"],
  "dependencyTypes": ["!peer"],
  "pinVersion": "18.2.0"
}

I don't think this quite works in this scenario though as @types/** packages tend to have their own patch versions a lot of the time. This feature being discussed in this issue will help a lot, we just need to come up with an approach for it.

EDIT: I wonder if an approach something like this would work, so those packages are treated as being one.

{
  "label": "Ensure react is all same version",
  "packages": ["**"],
-  "dependencies": ["react", "react-dom", "@types/react", "@types/react-dom"],
+  "aliases": ["react", "react-dom", "@types/react", "@types/react-dom"],
  "dependencyTypes": ["!peer"],
  "pinVersion": "18.2.0"
}

@moltar
Copy link

moltar commented Dec 23, 2023

Dropping some $0.02 worth of context here.

The way @types/* versions are managed is documented here: https://github.com/DefinitelyTyped/DefinitelyTyped#how-do-definitely-typed-package-versions-relate-to-versions-of-the-corresponding-library

It's not exactly SemVer, but SemVer-ish.

Also, one caveat/edge case, is that the version of the @type/* package can be lagging behind the package that is being typed, in both the patch and minor versions. E.g. foo can be at 2.10.7, but the latest @types/foo can be at 2.9.3, for multiple reasons, such as no types have changed leading, and including, to foo@2.10.7, or no one bothered to update the types.

So all of these heuristics would need to be encoded in the logic.

@JamieMason JamieMason changed the title Feature request: sync @type/xxx packages feat(core): sync @type/xxx packages Jan 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants