microsoft/typescript-go · error · Error
${publishedTypeScriptAliasPackageName} package.json did not
Error message
${publishedTypeScriptAliasPackageName} package.json did not contain platform optionalDependencies. What it means
Third validation inside getPublishedTypeScriptPackageJson: the alias package.json must contain an `optionalDependencies` object. That object maps platform package names (e.g. @typescript/native-preview-win32-x64) to versions, and getPublishedPlatformPackageLibDir later reads it to know which platform tarballs to fetch. Stock `typescript` from npm has no such field, so this check distinguishes the native-preview alias distribution from a plain typescript install.
Source
Thrown at Herebyfile.mjs:2213
const publishedPlatformPackageLibDirs = new Map();
const getPublishedTypeScriptPackageJson = memoize(() => {
const candidates = [
path.join(extensionDir, "node_modules", publishedTypeScriptAliasPackageName, "package.json"),
path.join(__dirname, "node_modules", publishedTypeScriptAliasPackageName, "package.json"),
];
for (const candidate of candidates) {
if (fs.existsSync(candidate)) {
const packageJson = JSON.parse(fs.readFileSync(candidate, "utf8"));
if (packageJson.name !== "typescript") {
throw new Error(`${publishedTypeScriptAliasPackageName} should alias the typescript package, but found ${packageJson.name}.`);
}
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() {
View on GitHub (pinned to 1bcfa18d79)
Solutions
- Restore the alias spec from the repo's package.json/package-lock.json (the version published alongside the native preview) and re-run `npm install`
- Verify the reinstalled `_extension/node_modules/@typescript/bundled-typescript/package.json` now lists platform packages under optionalDependencies
- If you maintain the alias package, ensure its package.json publishes the platform optionalDependencies map
Defensive patterns
Strategy: validation
Validate before calling
const pj = JSON.parse(fs.readFileSync(aliasPath, "utf8"));
if (pj.optionalDependencies === null || typeof pj.optionalDependencies !== "object" || Array.isArray(pj.optionalDependencies)) {
throw new Error(`${aliasPath} lacks platform optionalDependencies — wrong alias target, reinstall`);
} Prevention
- Keep the alias pointing at the native-preview distribution, not stock typescript
- After install, spot-check optionalDependencies lists @typescript/* platform packages
When it happens
Trigger: The alias resolved to a package without platform optionalDependencies — typically plain upstream `typescript` instead of the native-preview distribution, or an old/custom build of the alias published before platform packages existed.
Common situations: Someone changed the alias spec in package.json (or the lockfile) so `@typescript/bundled-typescript` now points at the regular typescript package; installing an alias version published by an older layout of this repo.
Related errors
- ${publishedTypeScriptAliasPackageName} should alias the type
- ${publishedTypeScriptAliasPackageName} package.json did not
- ${publishedTypeScriptAliasPackageName} does not depend on ${
- Published platform package ${npmPackageName}@${version} did
- Found external imports in .d.ts files:\n${importErrors.map(e
AI-assisted analysis of microsoft/typescript-go@1bcfa18d79 (2026-08-16).
Data as JSON: /api/errors/2c310b3c60283851.
Report an issue: GitHub.