Title: writeFileSync `data` as `Object` throws type error despite docs listing Object as a supported type · Issue #39152 · nodejs/node · GitHub
Open Graph Title: writeFileSync `data` as `Object` throws type error despite docs listing Object as a supported type · Issue #39152 · nodejs/node
X Title: writeFileSync `data` as `Object` throws type error despite docs listing Object as a supported type · Issue #39152 · nodejs/node
Description: Version: 14.17.0 & 16.4.0 Platform: local 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64 Subsystem: FS / Docs What steps will reproduce the bug? import { writeFileSync } ...
Open Graph Description: Version: 14.17.0 & 16.4.0 Platform: local 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64 Subsystem: FS / Docs What steps will repr...
X Description: Version: 14.17.0 & 16.4.0 Platform: local 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64 Subsystem: FS / Docs What steps will ...
Opengraph URL: https://github.com/nodejs/node/issues/39152
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"writeFileSync `data` as `Object` throws type error despite docs listing Object as a supported type","articleBody":"* **Version**: `14.17.0` \u0026 `16.4.0`\r\n* **Platform**: `local 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64`\r\n* **Subsystem**: FS / Docs\r\n\r\n### What steps will reproduce the bug?\r\n\r\n```js\r\nimport { writeFileSync } from 'fs';\r\n\r\nwriteFileSync('test.log', { foo: 'bar' });\r\n```\r\n\r\n### How often does it reproduce? Is there a required condition?\r\n\r\n100% (no special conditions)\r\n\r\n### What is the expected behavior?\r\n\r\nThe type(s) for `data` listed in the docs to work.\r\n\r\n### What do you see instead?\r\n\r\n```\r\nTypeError [ERR_INVALID_ARG_TYPE]: The \"data\" argument must be of type string or an\r\ninstance of Buffer, TypedArray, or DataView. Received an instance of Object\r\n at writeFileSync (node:fs:2136:5)\r\n```\r\n\r\n### Additional information\r\n\r\nfs docs for [14.x](https://nodejs.org/docs/latest-v14.x/api/fs.html#fs_fs_writefilesync_file_data_options) and [16.x](https://nodejs.org/docs/latest-v16.x/api/fs.html#fs_fs_writefilesync_file_data_options) both include `\u003cObject\u003e` as a type for writeFileSync's `data` argument:\r\n\r\n\u003e `data` `\u003cstring\u003e` | `\u003cBuffer\u003e` | `\u003cTypedArray\u003e` | `\u003cDataView\u003e` | `\u003cObject\u003e`","author":{"url":"https://github.com/JakobJingleheimer","@type":"Person","name":"JakobJingleheimer"},"datePublished":"2021-06-25T15:08:23.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":8},"url":"https://github.com/39152/node/issues/39152"}
| 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:5fdf484d-dd84-ff63-d6ac-1e4bd59943ee |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C228:1B6F9B:1636030:1ECD6B1:6A4DF29F |
| html-safe-nonce | d42baaf4d2c9f333740ace8fb315b74f7ffdbe3fbed0703b20cd62df91340885 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMjI4OjFCNkY5QjoxNjM2MDMwOjFFQ0Q2QjE6NkE0REYyOUYiLCJ2aXNpdG9yX2lkIjoiODQzNDg4Mzg4NjM5NjA3NjcwNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d6079e913818545307f01514cbe5b9e4f5711ccb015da9932e1033a5e1a27690 |
| hovercard-subject-tag | issue:930263419 |
| 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/nodejs/node/39152/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cf606e22225ef36e521224d04de233831ba2b8b628b5c16b12b8a0b0e32213bb/nodejs/node/issues/39152 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cf606e22225ef36e521224d04de233831ba2b8b628b5c16b12b8a0b0e32213bb/nodejs/node/issues/39152 |
| og:image:alt | Version: 14.17.0 & 16.4.0 Platform: local 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:31 PDT 2021; root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64 Subsystem: FS / Docs What steps will repr... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JakobJingleheimer |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5818716c93c6a2925b815402541a32814e43a7b1261c322b0c2df75224289566 |
| turbo-cache-control | no-preview |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| 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 | f4bb89367ca678f057d79b1abc45d6675b1bd5b2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width