Title: String indexer accepted as var type but not as class member type · Issue #178 · microsoft/TypeScript · GitHub
Open Graph Title: String indexer accepted as var type but not as class member type · Issue #178 · microsoft/TypeScript
X Title: String indexer accepted as var type but not as class member type · Issue #178 · microsoft/TypeScript
Description: Hi, I think this is a bug. Please see comments for details: interface ObjectHash { [key: string]: any; } // OK var defaults: ObjectHash = { title: "untitled", }; // This is error, expected defaults = ["a"]; declare class Model { defaults...
Open Graph Description: Hi, I think this is a bug. Please see comments for details: interface ObjectHash { [key: string]: any; } // OK var defaults: ObjectHash = { title: "untitled", }; // This is error, expected defaults...
X Description: Hi, I think this is a bug. Please see comments for details: interface ObjectHash { [key: string]: any; } // OK var defaults: ObjectHash = { title: "untitled", }; // This is error, expecte...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/178
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"String indexer accepted as var type but not as class member type","articleBody":"Hi,\n\nI think this is a bug. Please see comments for details:\n\n``` typescript\ninterface ObjectHash {\n [key: string]: any;\n}\n\n// OK \nvar defaults: ObjectHash = {\n title: \"untitled\",\n};\n\n// This is error, expected\ndefaults = [\"a\"];\n\ndeclare class Model {\n defaults: ObjectHash\n}\n\n// Index signatures of types '{ title: string }' and 'ObjectHash' are incompatibe.\n// Why?! Unexpected error.\nclass MyModel extends Model {\n defaults = {\n title: \"untitled\"\n };\n}\n\n// It works when assigned in the constructor\nclass MyModel1 extends Model {\n constructor() {\n // OK\n this.defaults = {\n title: \"untitled\"\n } \n super();\n }\n}\n\n// Trying different way\ndeclare class Model2 {\n // 'defaults' is method\n defaults(): ObjectHash\n}\n\n// Same here. Why is this an error? Is this a bug?\nclass MyModel2 extends Model2 {\n defaults() {\n return {\n title: \"untitled\"\n }\n }\n}\n```\n","author":{"url":"https://github.com/omidkrad","@type":"Person","name":"omidkrad"},"datePublished":"2014-07-22T01:29:37Z","url":"https://github.com/microsoft/TypeScript/issues/178"}
| 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:c7307047-a8c5-575e-d1ae-b3e3c9b0c128 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D320:3DD488:EA71A0:12A3608:6B010BE9 |
| html-safe-nonce | 55e69b27b0a64e0c2a4638169a6a5c8ee3df46ae9a0fc76b13483243060ff98c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzIwOjNERDQ4ODpFQTcxQTA6MTJBMzYwODo2QjAxMEJFOSIsInZpc2l0b3JfaWQiOiI3NjAxODE3OTQxMTYwMTMwMzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 92130fb00b0c469d94fb90b0467fe91c3f850a8ae18acf5cc3507d8c3facb71b |
| hovercard-subject-tag | issue:38361360 |
| 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/178/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3b2e4592b1db080291d52132fc328906d16866111b43f8c3827b79ed8d472319/microsoft/TypeScript/issues/178 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3b2e4592b1db080291d52132fc328906d16866111b43f8c3827b79ed8d472319/microsoft/TypeScript/issues/178 |
| og:image:alt | Hi, I think this is a bug. Please see comments for details: interface ObjectHash { [key: string]: any; } // OK var defaults: ObjectHash = { title: "untitled", }; // This is error, expected defaults... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | omidkrad |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| 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 | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width