Title: External modules that don't export anything emit empty declarations. · Issue #6022 · microsoft/TypeScript · GitHub
Open Graph Title: External modules that don't export anything emit empty declarations. · Issue #6022 · microsoft/TypeScript
X Title: External modules that don't export anything emit empty declarations. · Issue #6022 · microsoft/TypeScript
Description: Background - in RxJS we have a number of "operators" that extend our base Observable type. //src/Observable.ts class Observable { map:
Open Graph Description: Background - in RxJS we have a number of "operators" that extend our base Observable type. //src/Observable.ts class Observable { map:
X Description: Background - in RxJS we have a number of "operators" that extend our base Observable type. //src/Observable.ts class Observable { map: <R>(project: (x: T, ix?: number) => R, this...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/6022
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"External modules that don't export anything emit empty declarations.","articleBody":"Background - in RxJS we have a number of \"operators\" that extend our base Observable type.\n\n``` typescript\n//src/Observable.ts\nclass Observable {\n map: \u003cR>(project: (x: T, ix?: number) => R, thisArg?: any) => Observable\u003cR>;\n}\n```\n\n``` typescript\n// src/operators/map.ts\nexport function map\u003cT, R>(project: (x: T, ix?: number) => R, thisArg?: any): Observable\u003cR> {\n if (typeof project !== 'function') {\n throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');\n }\n return this.lift(new MapOperator(project, thisArg));\n}\n//snip\n```\n\nThis separation allows a user to import the `map` operator function and use it without bringing in the other 95 or so - without \"side-effects\":\n\n``` typescript\nimport {map} from 'rxjs/operators/map'\nmap.call(someObservable, (v) => v + 1 );\n```\n\nWithout functionBind, this is slightly unergonomic, so we defined a set of \"patch\" modules that import the `Observable` type and the the `map` operator, and patch the prototype there:\n\n``` typescript\n//rxjs/add/operators/map.ts\nimport {Observable} from '../../Observable';\nimport {map} from '../../operator/map';\nObservable.prototype.map = map;\n```\n\nWith the idea being a user should be able to simply `import 'rxjs/add/operators/map'` and have the prototype patched in the background.\n\nIssue:\n\nThe emitted `rxjs/add/operators/map.d.ts` file is emitted completely empty, and so when a user goes to `import 'rxjs/add/operators/map.ts'`, the Typescript compiler errors with\n\n```\nerror TS2656: \nExported external package typings file 'node_modules/rxjs/add/operator/map.d.ts' is not a module. \nPlease contact the package author to update the package definition.\n```\n\nDiscussed with @mhegazy \n\nCC @blesh @jeffbcross\n\nRxJS Issue: https://github.com/ReactiveX/RxJS/issues/1010\nSample file: https://github.com/ReactiveX/RxJS/blob/master/src/add/operator/map.ts \n","author":{"url":"https://github.com/robwormald","@type":"Person","name":"robwormald"},"datePublished":"2015-12-09T23:00:17Z","url":"https://github.com/microsoft/TypeScript/issues/6022"}
| 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:bbc212c5-2f6f-b5dd-b7f8-c63d030d3fa1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF30:3CBB3E:2A6137:35A3F3:6B0101A9 |
| html-safe-nonce | c7fb0a047e3bdb1c71f7f242253de0b2bc8d64f6862c0ff8cc48419cfbeb6fbc |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjMwOjNDQkIzRToyQTYxMzc6MzVBM0YzOjZCMDEwMUE5IiwidmlzaXRvcl9pZCI6IjkzOTYwMDU3ODI3Nzg2Nzk0NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 447cd94d6aca6caaded6ce3ea0a4a8961b20efbc32c81312b38cfb61a75067f9 |
| hovercard-subject-tag | issue:121361036 |
| 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/6022/issue_layout |
| twitter:image | https://opengraph.githubassets.com/849c8a4640277cc795407324d291a8a27985de90caefc882900038ee31e29028/microsoft/TypeScript/issues/6022 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/849c8a4640277cc795407324d291a8a27985de90caefc882900038ee31e29028/microsoft/TypeScript/issues/6022 |
| og:image:alt | Background - in RxJS we have a number of "operators" that extend our base Observable type. //src/Observable.ts class Observable { map: |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | robwormald |
| 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