Title: Incremental compile panics on a failed output write, or never retries it · Issue #64875 · microsoft/TypeScript · GitHub
Open Graph Title: Incremental compile panics on a failed output write, or never retries it · Issue #64875 · microsoft/TypeScript
X Title: Incremental compile panics on a failed output write, or never retries it · Issue #64875 · microsoft/TypeScript
Description: 🔎 Search Terms TS5033, Could not write file, panic, nil pointer dereference, diagnosticToStringBuilder, incremental, tsbuildinfo, up to date 🕗 Version & Regression Information This is the behavior in every version I tried: 7.0.2 and 7.1....
Open Graph Description: 🔎 Search Terms TS5033, Could not write file, panic, nil pointer dereference, diagnosticToStringBuilder, incremental, tsbuildinfo, up to date 🕗 Version & Regression Information This is the behavior ...
X Description: 🔎 Search Terms TS5033, Could not write file, panic, nil pointer dereference, diagnosticToStringBuilder, incremental, tsbuildinfo, up to date 🕗 Version & Regression Information This is the behav...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/64875
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incremental compile panics on a failed output write, or never retries it","articleBody":"### 🔎 Search Terms\n\nTS5033, Could not write file, panic, nil pointer dereference, diagnosticToStringBuilder, incremental, tsbuildinfo, up to date\n\n### 🕗 Version & Regression Information\n\n- This is the behavior in every version I tried: 7.0.2 and 7.1.0-dev.20261019.1, on Windows 11\n\n### 💻 Code\n\n`tsconfig.json`:\n\n```json\n{\n \"compilerOptions\": {\n \"incremental\": true,\n \"declaration\": true,\n \"rootDir\": \"src\",\n \"outDir\": \"dist\"\n }\n}\n```\n\n`src/a.ts` is `export const a = 1;` and `src/b.ts` is `export const b = 2;`. A directory where `a.js` goes makes that one write fail:\n\n```sh\nmkdir -p dist/a.js\ntsc -p .\n```\n\nThen the same project without `\"declaration\": true`:\n\n```sh\nmkdir -p dist/a.js\ntsc -p .\nrmdir dist/a.js\ntsc -b\ntsc -p .\n```\n\n### 🙁 Actual behavior\n\nWith `declaration`, `tsc -p .` and `tsc -b` panic instead of reporting the failed write:\n\n```\npanic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]\n...\ngithub.com/microsoft/TypeScript/tsc/internal/ast.(*SourceFile).FileName(...)\n\tgithub.com/microsoft/TypeScript/tsc/internal/ast/ast.go:2629\ngithub.com/microsoft/TypeScript/tsc/internal/execute/incremental.diagnosticToStringBuilder(...)\n\tgithub.com/microsoft/TypeScript/tsc/internal/execute/incremental/snapshot.go:411 +0x109\ngithub.com/microsoft/TypeScript/tsc/internal/execute/incremental.(*snapshot).computeSignatureWithDiagnostics(...)\n\tgithub.com/microsoft/TypeScript/tsc/internal/execute/incremental/snapshot.go:400 +0x11d\ngithub.com/microsoft/TypeScript/tsc/internal/execute/incremental.(*emitFilesHandler).getEmitOptions.func1(...)\n\tgithub.com/microsoft/TypeScript/tsc/internal/execute/incremental/emitfileshandler.go:212 +0x112\n```\n\nWithout `declaration`, the first run reports `error TS5033: Could not write file '…/dist/a.js': open …/dist/a.js: is a directory.`, and once the directory is gone no run writes `dist/a.js`: `tsc -b` exits 0 with \"Project 'tsconfig.json' is up to date because newest input 'src/a.ts' is older than output 'tsconfig.tsbuildinfo'\", and `tsc -p .` exits 1 with the same TS5033 about the removed directory.\n\n### 🙂 Expected behavior\n\nThe run that cannot write `dist/a.js` reports TS5033 and fails, and the next run, with the path writable again, writes `dist/a.js`.\n\n### Additional information about the issue\n\nThe write failure's TS5033 has no file, and [`diagnosticToStringBuilder`](https://github.com/microsoft/TypeScript/blob/5237fd46890956e4bb8177a1a05dcd69e4166560/tsc/internal/execute/incremental/snapshot.go#L405-L411) calls `diagnostic.File().FileName()` whenever the diagnostic's file is not the one being emitted. A write can fail for a reason that passes, such as another process holding the file, so the next run needs to write it again.\n","author":{"url":"https://github.com/YevheniiKotyrlo","@type":"Person","name":"YevheniiKotyrlo"},"datePublished":"2026-10-19T18:08:33Z","url":"https://github.com/microsoft/TypeScript/issues/64875"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5abd6c77-8b93-560f-985b-2043d3f3a275 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC6E:17A21E:C79479:102568C:6B063F1E |
| html-safe-nonce | d764e6c44727f21dd610b4a9bff844eddc2a92bea604e730918f147d6276a42e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzZFOjE3QTIxRTpDNzk0Nzk6MTAyNTY4Qzo2QjA2M0YxRSIsInZpc2l0b3JfaWQiOiI2NDMyNDYwNTg1NTc3MTAzMTM0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 91f219d80db7220c27da27c45ab0794f37e33d18f8b26d47807603db485a9475 |
| hovercard-subject-tag | issue:5929024847 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/64875/issue_layout |
| twitter:image | https://opengraph.githubassets.com/42ea0f35cdb8d645adcc9807ec0f9fc707e07988d3853beef1ce21e07cd6b52c/microsoft/TypeScript/issues/64875 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/42ea0f35cdb8d645adcc9807ec0f9fc707e07988d3853beef1ce21e07cd6b52c/microsoft/TypeScript/issues/64875 |
| og:image:alt | 🔎 Search Terms TS5033, Could not write file, panic, nil pointer dereference, diagnosticToStringBuilder, incremental, tsbuildinfo, up to date 🕗 Version & Regression Information This is the behavior ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | YevheniiKotyrlo |
| hostname | github.com |
| expected-hostname | github.com |
| None | dcf72c457c022486d23c3cbb0dd21aba537a87611ca9ddabd1799cf2eaa9b297 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 0f38f5735226749ec5e08a8649dce4cb2613d9ad |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width