Title: Star-imported module should conform to the type of a string-indexed object · Issue #17622 · microsoft/TypeScript · GitHub
Open Graph Title: Star-imported module should conform to the type of a string-indexed object · Issue #17622 · microsoft/TypeScript
X Title: Star-imported module should conform to the type of a string-indexed object · Issue #17622 · microsoft/TypeScript
Description: TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx) Suppose I have this module: // foo.ts export const x = 3 export const y = 5 Conceptually this module represents a map of strings to numbers, { [k: string]: number }, however if I t...
Open Graph Description: TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx) Suppose I have this module: // foo.ts export const x = 3 export const y = 5 Conceptually this module represents a map of strings to numbers,...
X Description: TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx) Suppose I have this module: // foo.ts export const x = 3 export const y = 5 Conceptually this module represents a map of strings to numbers,...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/17622
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Star-imported module should conform to the type of a string-indexed object","articleBody":"**TypeScript Version:** 2.4.0 / nightly (2.5.0-dev.201xxxxx)\r\n\r\nSuppose I have this module:\r\n\r\n```ts\r\n// foo.ts\r\n\r\nexport const x = 3\r\nexport const y = 5\r\n```\r\n\r\nConceptually this module represents a map of strings to numbers, `{ [k: string]: number }`, however if I try to use it directly as such I get a type error:\r\n\r\n```ts\r\n// bar.ts\r\n\r\nimport * as foo from './foo'\r\n\r\nfunction f(map: { [k: string]: number }) {\r\n // ...\r\n}\r\n\r\nf(foo)\r\n//^^^ Argument of type 'typeof \"/Users/tom/code/example/src/foo\"' is not assignable to parameter of type '{ [k: string]: number; }'.\r\n// Index signature is missing in type 'typeof \"/Users/tom/code/example/src/foo\"'.\r\n```\r\n\r\nFortunately there is a workaround: I can simply spread and recompose the module to make it conform to the expected type:\r\n\r\n```ts\r\nf({ ...foo }) // this type checks!\r\n```\r\n\r\nHowever it'd be nice if the more straightforward approach just worked!","author":{"url":"https://github.com/pelotom","@type":"Person","name":"pelotom"},"datePublished":"2017-08-04T20:59:14Z","url":"https://github.com/microsoft/TypeScript/issues/17622"}
| 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:f2c357ea-d1ab-5b12-d04d-8965773c86cd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C35E:DB09F:A35223:D1B8EA:6B00F546 |
| html-safe-nonce | 130e6e35c74d0ff9e1538b45f1e7f858c7fc8d3dd44df56f5a9e1dd5366e299a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzVFOkRCMDlGOkEzNTIyMzpEMUI4RUE6NkIwMEY1NDYiLCJ2aXNpdG9yX2lkIjoiNTQ3NzU3MTc4MDk0NjIyODU1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c27b2b98766c0f238256846c0177d07abd6cfd878ed74b918cbfa4bef9003315 |
| hovercard-subject-tag | issue:248115930 |
| 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/17622/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ca1e74b4204802790d8aee1d3913f66d14bd2f6249fc998196eabd6103e5234a/microsoft/TypeScript/issues/17622 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ca1e74b4204802790d8aee1d3913f66d14bd2f6249fc998196eabd6103e5234a/microsoft/TypeScript/issues/17622 |
| og:image:alt | TypeScript Version: 2.4.0 / nightly (2.5.0-dev.201xxxxx) Suppose I have this module: // foo.ts export const x = 3 export const y = 5 Conceptually this module represents a map of strings to numbers,... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pelotom |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width