Title: Error while accessing Namespace level variables from multiple files defining the same namespace. · Issue #6457 · microsoft/TypeScript · GitHub
Open Graph Title: Error while accessing Namespace level variables from multiple files defining the same namespace. · Issue #6457 · microsoft/TypeScript
X Title: Error while accessing Namespace level variables from multiple files defining the same namespace. · Issue #6457 · microsoft/TypeScript
Description: I have two files main.ts and secondfile.ts defining a namespace System.Parent.Level1Child Below are the contents of main.ts namespace System.Parent.Level1Child{ var parameterToShareBetweenFiles: number = 0; export class ChildClass1{ cons...
Open Graph Description: I have two files main.ts and secondfile.ts defining a namespace System.Parent.Level1Child Below are the contents of main.ts namespace System.Parent.Level1Child{ var parameterToShareBetweenFiles: nu...
X Description: I have two files main.ts and secondfile.ts defining a namespace System.Parent.Level1Child Below are the contents of main.ts namespace System.Parent.Level1Child{ var parameterToShareBetweenFiles: nu...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/6457
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Error while accessing Namespace level variables from multiple files defining the same namespace.","articleBody":"I have two files `main.ts` and `secondfile.ts` defining a namespace `System.Parent.Level1Child` \n\nBelow are the contents of `main.ts`\n\n```\nnamespace System.Parent.Level1Child{\n var parameterToShareBetweenFiles: number = 0;\n export class ChildClass1{\n constructor(){\n parameterToShareBetweenFiles += 1;\n }\n }\n}\n```\n\nBelow are the contents of `secondfile.ts`\n\n```\n/// \u003creference path=\"main\" />\n\nnamespace System.Parent.Level1Child{\n export class ChildClass2{\n constructor(){\n parameterToShareBetweenFiles += 1;\n }\n } \n}\n```\n\nSince I am extending the same namespace, I would expect that the `parameterToShareBetweenFiles` should be available in the secondfile.ts but the compiler throws\n\n> error TS2304: Cannot find name 'parameterToShareBetweenFiles'\n\nI believe this is a Bug and needs to be fixed. Because the error doesn't come if the class definition for ChildClass2 is brought into the `main.ts` file as below. Does this mean that the entire namespace has to be defined in a single file? That is very inconvenient especially with multiple developers contributing to the same namespace.\n\n```\nnamespace System.Parent.Level1Child{\n var parameterToShareBetweenFiles: number = 0;\n export class ChildClass1{\n constructor(){\n parameterToShareBetweenFiles += 1;\n }\n }\n export class ChildClass2{\n constructor(){\n parameterToShareBetweenFiles += 1;\n }\n } \n}\n```\n","author":{"url":"https://github.com/seshualluvada","@type":"Person","name":"seshualluvada"},"datePublished":"2016-01-12T21:13:43Z","url":"https://github.com/microsoft/TypeScript/issues/6457"}
| 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:76d4b948-3f11-56fe-a0ee-7e3ea5cf245c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C3FE:19E4BB:29B9E1:364264:6B00CE8D |
| html-safe-nonce | a8bed94573566ee6e67918b00c1820765c1372e429f35481037e32ae9aaf53e3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDM0ZFOjE5RTRCQjoyOUI5RTE6MzY0MjY0OjZCMDBDRThEIiwidmlzaXRvcl9pZCI6IjQ1MTk4MzIxMDE1Nzg2NTc0MjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 666e7e209a0983d1b2463f1b0f2432bae42b3f84f349f291d6049074ff973757 |
| hovercard-subject-tag | issue:126276905 |
| 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/6457/issue_layout |
| twitter:image | https://opengraph.githubassets.com/633f846bb88e3a769fe7133058a1b51cad90a4e495bef935c82ea9988f9a855b/microsoft/TypeScript/issues/6457 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/633f846bb88e3a769fe7133058a1b51cad90a4e495bef935c82ea9988f9a855b/microsoft/TypeScript/issues/6457 |
| og:image:alt | I have two files main.ts and secondfile.ts defining a namespace System.Parent.Level1Child Below are the contents of main.ts namespace System.Parent.Level1Child{ var parameterToShareBetweenFiles: nu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | seshualluvada |
| hostname | github.com |
| expected-hostname | github.com |
| None | 85bbdfe2b6ba16e234513bc6ceff5d848ef8449820c900692a2b4e67061931e5 |
| 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 | 4943239a6d2c591325dad6e5c313e1cafda877f6 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width