Title: require('file.json') in JS causes error TS2307. · Issue #15987 · microsoft/TypeScript · GitHub
Open Graph Title: require('file.json') in JS causes error TS2307. · Issue #15987 · microsoft/TypeScript
X Title: require('file.json') in JS causes error TS2307. · Issue #15987 · microsoft/TypeScript
Description: TypeScript Version: 2.3 When checkJS is enabled, requireing a JSON file in a js src file is treated as an error. Code const config = require('./config.json'); Expected behavior: config is treated as a var of type any, or for bonus points...
Open Graph Description: TypeScript Version: 2.3 When checkJS is enabled, requireing a JSON file in a js src file is treated as an error. Code const config = require('./config.json'); Expected behavior: config is treated a...
X Description: TypeScript Version: 2.3 When checkJS is enabled, requireing a JSON file in a js src file is treated as an error. Code const config = require('./config.json'); Expected behavior: config is t...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/15987
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"require('file.json') in JS causes error TS2307.","articleBody":"\u003c!-- BUGS: Please use this template. -->\r\n\u003c!-- QUESTIONS: This is not a general support forum! Ask Qs at http://stackoverflow.com/questions/tagged/typescript -->\r\n\u003c!-- SUGGESTIONS: See https://github.com/Microsoft/TypeScript-wiki/blob/master/Writing-Good-Design-Proposals.md -->\r\n\r\n**TypeScript Version:** 2.3\r\n\r\nWhen checkJS is enabled, `require`ing a JSON file in a js src file is treated as an error.\r\n\r\n**Code**\r\n```js\r\nconst config = require('./config.json');\r\n```\r\n\r\n**Expected behavior:**\r\n`config` is treated as a var of type `any`, or for bonus points, an anonymous interface with the shape as defined in the relevant JSON file.\r\n**Actual behavior:**\r\n`error TS2307: Cannot find module './config.json'`.","author":{"url":"https://github.com/akdor1154","@type":"Person","name":"akdor1154"},"datePublished":"2017-05-22T03:29:32Z","url":"https://github.com/microsoft/TypeScript/issues/15987"}
| 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:b4c0935d-5575-fc00-d087-a6406720b2c8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EBA2:21AC3F:31241CD:3E37EDE:6B01AF93 |
| html-safe-nonce | 9e1c99df6b46d8497d95fd1468ed77ec9a84bfebbd0852bc7a0a12c5612b560e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQkEyOjIxQUMzRjozMTI0MUNEOjNFMzdFREU6NkIwMUFGOTMiLCJ2aXNpdG9yX2lkIjoiMTM0NTMwNzg5NjM0MjIyODg4MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 726e2557af9c680a9dcf187474760994989188617831d8816588ddc23a28f3ab |
| hovercard-subject-tag | issue:230276086 |
| 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/15987/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f3cfd40574bf80547d03387951f86489e0c8f7327f52c217f7378ab79ae8fdf6/microsoft/TypeScript/issues/15987 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f3cfd40574bf80547d03387951f86489e0c8f7327f52c217f7378ab79ae8fdf6/microsoft/TypeScript/issues/15987 |
| og:image:alt | TypeScript Version: 2.3 When checkJS is enabled, requireing a JSON file in a js src file is treated as an error. Code const config = require('./config.json'); Expected behavior: config is treated a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | akdor1154 |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width