Title: Create "Global / External-agnostic" declaration files without exposing internal definitions · Issue #2018 · microsoft/TypeScript · GitHub
Open Graph Title: Create "Global / External-agnostic" declaration files without exposing internal definitions · Issue #2018 · microsoft/TypeScript
X Title: Create "Global / External-agnostic" declaration files without exposing internal definitions · Issue #2018 · microsoft/TypeScript
Description: Say I'm writing a declaration file for an external library that both exposes a global and supports CommonJS. According to the handbook I would write that like this: module zoo { function open(): void; } declare module "zoo" { export = zo...
Open Graph Description: Say I'm writing a declaration file for an external library that both exposes a global and supports CommonJS. According to the handbook I would write that like this: module zoo { function open(): vo...
X Description: Say I'm writing a declaration file for an external library that both exposes a global and supports CommonJS. According to the handbook I would write that like this: module zoo { function open()...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/2018
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Create \"Global / External-agnostic\" declaration files without exposing internal definitions","articleBody":"Say I'm writing a declaration file for an external library that both exposes a global and supports CommonJS. According to the handbook I would write that like this:\n\n```\nmodule zoo {\n function open(): void;\n}\n\ndeclare module \"zoo\" {\n export = zoo;\n}\n```\n\nAnd then the usage would be this:\n\n```\n// Either\nimport x = require('zoo');\nx.open();\n// or\nzoo.open();\n```\n\nThe problem is that while the above would compile when using external modules, at run-time it would fail since the \"zoo\" identifier doesn't actually exist. Is there any way to write declaration files such that you can split them into two separate files (one for internal, one for external) so that you only reference the one you intend on using but not actually duplicate the definitions in those files? For example\n\n```\n// zoo.d.ts\ndeclare module \"zoo\" {\n export = zoo;\n}\n\n// zoo-internal.d.ts\n\n/// \u003creference path=\"zoo.d.ts\" />\nmodule zoo {\n // this doesn't work but illustrates what I'm trying to accomplish\n import zoo = require('zoo')\n export = zoo;\n}\n```\n\nOr any thoughts on another way to accomplish the same goals in a single file?\n","author":{"url":"https://github.com/jbrantly","@type":"Person","name":"jbrantly"},"datePublished":"2015-02-12T14:47:59Z","url":"https://github.com/microsoft/TypeScript/issues/2018"}
| 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:0d4283bc-969c-4e87-1af3-1768ed12fa2a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D35E:1C94F:3C2205:4C8AB4:6B010867 |
| html-safe-nonce | 86f95d4ee9643b73a1227e5ab146c6093a837b2f47241275cf07724d9fdeb955 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMzVFOjFDOTRGOjNDMjIwNTo0QzhBQjQ6NkIwMTA4NjciLCJ2aXNpdG9yX2lkIjoiNDkzMDIzMzc4NDUzNzc3ODI3OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2d746b7cc0fa11d9285fe0ac67176b4acd1da296d88b766c69021ae7699294ac |
| hovercard-subject-tag | issue:57469172 |
| 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/2018/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f60cbdcf7283282e834dda7e7b29a5a31e5ddda25bb9108de46497e836af9ccd/microsoft/TypeScript/issues/2018 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f60cbdcf7283282e834dda7e7b29a5a31e5ddda25bb9108de46497e836af9ccd/microsoft/TypeScript/issues/2018 |
| og:image:alt | Say I'm writing a declaration file for an external library that both exposes a global and supports CommonJS. According to the handbook I would write that like this: module zoo { function open(): vo... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jbrantly |
| 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