@@ -49,9 +49,20 @@ async function updateNodeVersion() {
4949 "utf8" ,
5050 ) ;
5151
52+ // The @types /node version needs to match the first two parts of the Node
53+ // version, e.g. if the Node version is 18.17.3, the @types/node version
54+ // should be 18.17.*. This corresponds with the documentation at
55+ // https://github.com/definitelytyped/definitelytyped#how-do-definitely-typed-package-versions-relate-to-versions-of-the-corresponding-library
56+ // "The patch version of the type declaration package is unrelated to the library patch version. This allows
57+ // Definitely Typed to safely update type declarations for the same major/minor version of a library."
58+ // 18.17.* is equivalent to >=18.17.0 <18.18.0
59+ const typesNodeVersion = versionInformation . nodeVersion
60+ . split ( "." )
61+ . slice ( 0 , 2 )
62+ . join ( "." ) ;
63+
5264 packageJson . engines . node = `^${ versionInformation . nodeVersion } ` ;
53- packageJson . devDependencies [ "@types/node" ] =
54- `${ versionInformation . nodeVersion } ` ;
65+ packageJson . devDependencies [ "@types/node" ] = `${ typesNodeVersion } .*` ;
5566
5667 await outputFile (
5768 join ( extensionDirectory , "package.json" ) ,
@@ -61,6 +72,11 @@ async function updateNodeVersion() {
6172 console . log ( "Updated package.json, now running npm install" ) ;
6273
6374 execSync ( "npm install" , { cwd : extensionDirectory , stdio : "inherit" } ) ;
75+ // Always use the latest patch version of @types /node
76+ execSync ( "npm upgrade @types/node" , {
77+ cwd : extensionDirectory ,
78+ stdio : "inherit" ,
79+ } ) ;
6480
6581 console . log ( "Node version updated successfully" ) ;
6682}
0 commit comments