jeffijoe / typesync

Install missing TypeScript typings for dependencies in your package.json.
MIT License
1.51k stars 21 forks source link

Seemingly incorrect @types versions #78

Closed devinrhode2 closed 2 years ago

devinrhode2 commented 3 years ago

In our package.json, we have dependency:

"react": "~16.13.1",

Running yarn why clearly shows we have 16.13.1 installed.

After running npx typesync - I have:

"@types/react": "~17.0.24",

But... this is very clearly wrong... Unless there's something special I don't understand about react 16->17 types

devinrhode2 commented 3 years ago

I believe I had deleted all @types packages from package.json before getting this result.

Although, I certainly did still have this package installed inside of my node_modules:

"@types/react": "^16.9.48",

Could this have had an effect?

jeffijoe commented 3 years ago

My best guess is that there is no 16.13 range of the @types/react package, and since you are using the ~ range specifier, TypeSync can't find a version that matches, and so it picks the latest available as a fallback.

TypeSync uses the satisfies function from the semver package for this.

devinrhode2 commented 2 years ago

I think best thing people can do in similar situation is to just open up npmjs.com/package/@types/FOO and browse the available versions, and hand-pick a package. That, or just install/update them as you work on your features/fixes