Fix axios header type narrowing in GLM file upload (re-apply)#4
Merged
Conversation
In axios v1 response.headers is AxiosHeaders, so response.headers['content-type'] is typed as string | number | true | string[] | AxiosHeaders. Assigning that union to a string-typed local fails strict type checking under ts-node, which is what blocks 'npm run dev:backend'. Coerce through a typeof check so mimeType stays a string. Note: the same fix was previously pushed to PR #3 as a follow-up commit, but PR #3 was merged before that commit landed, so main still carried the broken line. Re-applying it directly here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request was generated by @kiro-agent 👻
Comment with /kiro fix to address specific feedback or /kiro all to address everything.
Learn about Kiro autonomous agent
PR #3 was merged before the follow-up "Fix axios header type narrowing in GLM file upload" commit landed, so
mainstill carries the broken line that blocksnpm run dev:backend:In axios v1
response.headersisAxiosHeaders, soresponse.headers['content-type']is typed asstring | number | true | string[] | AxiosHeadersrather thanstring | undefined. Assigning that union to astringlocal fails strict type checking under ts-node.This re-applies the one-line fix: narrow the value with a
typeof === 'string'check, falling back tomime.lookup(filename)and the generic octet-stream default for non-string headers.Test plan
git checkout main, pull this branch, runnpm run devand confirm the backend starts without TS errors.content-typeheader.