Title: How to import generic function type declaration from one javascript file to another? · Issue #29964 · microsoft/TypeScript · GitHub
Open Graph Title: How to import generic function type declaration from one javascript file to another? · Issue #29964 · microsoft/TypeScript
X Title: How to import generic function type declaration from one javascript file to another? · Issue #29964 · microsoft/TypeScript
Description: TypeScript Version: 3.3.3 Search Terms: import, typedef, callback jsCheck I have an issue with importing generic function type declared with @callback in another file. Here is example: In file1.js I've defined generic function with templ...
Open Graph Description: TypeScript Version: 3.3.3 Search Terms: import, typedef, callback jsCheck I have an issue with importing generic function type declared with @callback in another file. Here is example: In file1.js ...
X Description: TypeScript Version: 3.3.3 Search Terms: import, typedef, callback jsCheck I have an issue with importing generic function type declared with @callback in another file. Here is example: In file1.js ...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/29964
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"How to import generic function type declaration from one javascript file to another?","articleBody":"\r\n**TypeScript Version:** 3.3.3\r\n\r\n**Search Terms:** import, typedef, callback jsCheck\r\n\r\nI have an issue with importing generic function type declared with ```@callback``` in another file. \r\n\r\nHere is example:\r\n\r\nIn file1.js I've defined generic function with template parameter\r\n```js\r\n // file1.js\r\n /**\r\n * @template T\r\n * @template {Error} E\r\n * @callback CallbackWithResult\r\n * @param {E|null} error\r\n * @param {T} [result]\r\n */\r\n```\r\nAnd in another file I've imported that declaration\r\n```js\r\n // file2.js\r\n\r\n /** @typedef {import('./file1').CallbackWithResult} CallbackWithResult */\r\n \r\n /**\r\n * @param {CallbackWithResult\u003cnumber>} callback\r\n */\r\n function doSomething(callback) {\r\n callback(null, 42);\r\n }\r\n```\r\n\r\nAttempting to check file2.js gives following errors\r\n```bash\r\n file2.js:4:15 - error TS2314: Generic type 'CallbackWithResult' requires 2 type argument(s).\r\n \r\n 4 /** @typedef {import('./file1').CallbackWithResult} CallbackWithResult */\r\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n \r\n file2.js:7:12 - error TS2315: Type 'CallbackWithResult' is not generic.\r\n \r\n 7 * @param {CallbackWithResult\u003cnumber>} callback\r\n ~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n```\r\n\r\nQuestion is: how to properly import generic declarations without defining another set of template variables?","author":{"url":"https://github.com/ArenSH","@type":"Person","name":"ArenSH"},"datePublished":"2019-02-19T08:03:28Z","url":"https://github.com/microsoft/TypeScript/issues/29964"}
| 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:9cd0e3cd-6ec8-bc11-87e4-4faa2cb3b4f8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BBB8:76F02:87C9D3:B0F05F:6B00DD83 |
| html-safe-nonce | d5ed00529a404aa7cae79688bcdd53e701705225d333ba5f6ffd4a143d50bc9a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQkI4Ojc2RjAyOjg3QzlEMzpCMEYwNUY6NkIwMEREODMiLCJ2aXNpdG9yX2lkIjoiMjQzODg3NjI0NzE1ODIxODExNSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e4cb0c08cc5098fe19bece84d387bfd830c4f601bbf4e4fff6334be6f9f4d61e |
| hovercard-subject-tag | issue:411793259 |
| 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/29964/issue_layout |
| twitter:image | https://opengraph.githubassets.com/738d5c7f76fadced638d5845186c89e5ae53f696c0d8db5f1ed3a93a2b8b4f36/microsoft/TypeScript/issues/29964 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/738d5c7f76fadced638d5845186c89e5ae53f696c0d8db5f1ed3a93a2b8b4f36/microsoft/TypeScript/issues/29964 |
| og:image:alt | TypeScript Version: 3.3.3 Search Terms: import, typedef, callback jsCheck I have an issue with importing generic function type declared with @callback in another file. Here is example: In file1.js ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ArenSH |
| hostname | github.com |
| expected-hostname | github.com |
| None | 043c3f30fbcbe2c6c8e729e10cbbbc90c406546f9fbbb67c648d38f6b7d16daf |
| 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 | 5425dc24e8bd8d6fca9641a12afc984825a43875 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width