{"record":{"id":"a0b3b8343a3556be","repo":"microsoft/typescript-go","slug":"refusing-to-publish-typescript-with-the-latest-t","errorCode":null,"errorMessage":"Refusing to publish 'typescript' with the latest tag from non-release version ${version}.","messagePattern":"Refusing to publish 'typescript' with the latest tag from non-release version (.+?)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"Herebyfile.mjs","lineNumber":1240,"sourceCode":"        version += `-${options.setPrerelease}`;\r\n    }\r\n    else if (match[2]) {\r\n        version += match[2];\r\n    }\r\n\r\n    return version;\r\n});\r\n\r\nfunction getPublishTag() {\r\n    if (publishAsTypescript) {\r\n        const version = getVersion();\r\n        if (!version) {\r\n            throw new Error(\"Publishing as 'typescript' requires a version before selecting an npm tag.\");\r\n        }\r\n        const match = version.match(/-(dev|beta|rc)(?:[.-]|$)/);\r\n        if (match?.[1]) return match[1] === \"dev\" ? \"next\" : match[1];\r\n        if (version === nativePreviewReleaseVersion) return \"latest\";\r\n        throw new Error(`Refusing to publish 'typescript' with the latest tag from non-release version ${version}.`);\r\n    }\r\n    return \"latest\";\r\n}\r\n\r\nconst extensionDir = path.resolve(\"./_extension\");\r\nconst nightlyExtensionDir = path.resolve(\"./_extension-nightly\");\r\nconst builtNpm = path.resolve(\"./built/npm\");\r\nconst builtVsix = path.resolve(\"./built/vsix\");\r\nconst builtPublishedPlatformPackages = path.resolve(\"./built/published-platform-packages\");\r\nconst builtSignTmp = path.resolve(\"./built/sign-tmp\");\r\nconst publishedTypeScriptAliasPackageName = \"@typescript/bundled-typescript\";\r\nconst releasePackageEnv = { COREPACK_ENABLE_STRICT: \"0\" };\r\n\r\nconst getSignTempDir = memoize(async () => {\r\n    const dir = path.resolve(builtSignTmp);\r\n    await rimraf(dir);\r\n    await fs.promises.mkdir(dir, { recursive: true });\r\n    return dir;\r","sourceCodeStart":1222,"sourceCodeEnd":1258,"githubUrl":"https://github.com/microsoft/typescript-go/blob/1bcfa18d79a3be41772223d5c05dfe4480e614ff/Herebyfile.mjs#L1222-L1258","documentation":"When publishing as 'typescript', the npm dist-tag is derived from the version: dev maps to next, beta/rc pass through, and 'latest' is allowed only for the exact hardcoded nativePreviewReleaseVersion. Any other version without a dev/beta/rc prerelease would otherwise be published as latest, so the script refuses.","triggerScenarios":"Publishing with a plain X.Y.Z version (no prerelease suffix, no --setPrerelease) while publishAsTypescript is true and the version does not equal nativePreviewReleaseVersion.","commonSituations":"version.go lost its prerelease suffix on a branch; attempting a stable release without hardcoding nativePreviewReleaseVersion on a release branch; running publish tasks with unexpected getVersion() results.","solutions":["Publish from main with an explicit prerelease: --setPrerelease=beta.1 or dev.YYYYMMDD","For a stable release, set nativePreviewReleaseVersion to that exact version on the native release branch","Log/inspect the computed getVersion() value before running publish tasks"],"exampleFix":"# before\nhereby publish --forRelease  # version 5.9.2, no prerelease\n\n# after\nhereby publish --forRelease --setPrerelease=beta.1  # version 5.9.2-beta.1 -> tag beta","handlingStrategy":"validation","validationCode":"function assertPublishTagSafe(version, hardcoded) {\n  const m = version.match(/-(dev|beta|rc)(?:[.-]|$)/);\n  const isPrerelease = !!m;\n  const isHardcodedStable = version === hardcoded;\n  if (!isPrerelease && !isHardcodedStable) {\n    throw new Error(`Refusing latest tag for ${version}; pass --setPrerelease or hardcode the release version.`);\n  }\n}","typeGuard":"/** @param {string} version @returns {boolean} */\nfunction hasPublishablePrerelease(version) {\n  return /-(dev|beta|rc)(?:[.-]|$)/.test(version);\n}","tryCatchPattern":"try { publish(); } catch (e) { if (/Refusing to publish/.test(e.message)) { stop the pipeline; never bypass with --tag latest by hand; } throw e; }","preventionTips":["Never publish as 'typescript' without a dev/beta/rc prerelease or a hardcoded stable version","Dry-run publish tasks and inspect the resolved version and dist-tag first","Treat this error as a hard stop in CI, not a warning"],"tags":["release","npm","publishing","safety"],"backgroundTag":null,"analyzedSha":"1bcfa18d79a3be41772223d5c05dfe4480e614ff","analyzedAt":"2026-08-16T02:12:00.115Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}