I know that some npm packages don’t include types and due to that community creates @types/packagename to supply types. Since both are packages how does one know which version of types package to use with the chosen version of library package?
I know that some npm packages don’t include types and due to that community creates @types/packagename to supply types. Since both are packages how does one know which version of types package to use with the chosen version of library package?
The major and minor version numbers of the @types/packagename package will match the major and minor version numbers of the packagename package. The patch numbers do not match: the types package will start with the patch number 0 and this will be incremented for every update to the types package for the same major/minor versions of the library.
For example, if you are using packagename@1.2.3, you would install the latest @types/packagename@1.2.x.
You can read more on ‘How do Definitely Typed package versions relate to versions of the corresponding library?’ on the DefinitelyTyped repository (permalink), which is where the source of the @types packages are located.