microsoft/typescript-go · error · Error

usePublishedPlatformPackagesForVsix requires ${publishedType

Error message

usePublishedPlatformPackagesForVsix requires ${publishedTypeScriptAliasPackageName}'s installed version (${version}) to match release version ${expectedVersion}.

What it means

getPublishedTypeScriptVersion compares the installed `@typescript/bundled-typescript` version with getVersion() (the release version derived from --setPrerelease/nativePreviewReleaseVersion). When usePublishedPlatformPackagesForVsix is enabled, VSIXes must embed lib/ dirs from exactly the published platform packages matching the release, so a mismatch aborts the build instead of producing a VSIX with mixed-version binaries.

Source

Thrown at Herebyfile.mjs:2226

            }
            if (!packageJson.version || typeof packageJson.version !== "string") {
                throw new Error(`${publishedTypeScriptAliasPackageName} package.json did not contain a version.`);
            }
            if (!packageJson.optionalDependencies || typeof packageJson.optionalDependencies !== "object") {
                throw new Error(`${publishedTypeScriptAliasPackageName} package.json did not contain platform optionalDependencies.`);
            }
            return packageJson;
        }
    }

    throw new Error(`Could not find ${publishedTypeScriptAliasPackageName}; run npm install first.`);
});

function getPublishedTypeScriptVersion() {
    const version = getPublishedTypeScriptPackageJson().version;
    const expectedVersion = getVersion();
    if (usePublishedPlatformPackagesForVsix && version !== expectedVersion) {
        throw new Error(`usePublishedPlatformPackagesForVsix requires ${publishedTypeScriptAliasPackageName}'s installed version (${version}) to match release version ${expectedVersion}.`);
    }
    return version;
}

function checkPublishedPlatformPackagesForVsix() {
    if (!options.forRelease) {
        throw new Error("usePublishedPlatformPackagesForVsix requires forRelease");
    }
    getPublishedTypeScriptVersion();
}

const getPackageLock = memoize(() => JSON.parse(fs.readFileSync(path.join(__dirname, "package-lock.json"), "utf8")));

/**
 * @param {string} npmPackageName
 */
async function getPublishedPlatformPackageLibDir(npmPackageName) {
    let promise = publishedPlatformPackageLibDirs.get(npmPackageName);

View on GitHub (pinned to 1bcfa18d79)

Solutions

  1. Re-run `npm install` at the repo root so `@typescript/bundled-typescript` resolves to the release version, then retry
  2. If the intended release version is the installed one, fix what you pass: align --setPrerelease (or nativePreviewReleaseVersion) with the installed alias version
  3. In CI, always run install after computing the version, and don't cache node_modules across version bumps

Example fix

# before (alias installed at dev.24.9, releasing dev.25.0)
npx hereby native-preview:release --forRelease --setPrerelease=dev.25.0

# after
npm install && npx hereby native-preview:release --forRelease --setPrerelease=dev.25.0
Defensive patterns

Strategy: validation

Validate before calling

const installed = require("@typescript/bundled-typescript/package.json").version;
const expected = computeReleaseVersion(); // same source hereby uses
if (installed !== expected) {
  throw new Error(`Alias ${installed} != release ${expected} — run npm install`);
}

Prevention

When it happens

Trigger: Running VSIX packaging with usePublishedPlatformPackagesForVsix while node_modules still holds an older (or newer) alias than the version hereby computes — e.g. after bumping --setPrerelease or the hardcoded nativePreviewReleaseVersion without reinstalling.

Common situations: Version bumped in CI but the install step was skipped or cached with the previous version; switching between release lines; local node_modules stale after pulling version changes.

Related errors


AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16). Data as JSON: /api/errors/d3e8896b2c1a8473. Report an issue: GitHub.