Title: Feature request: better support for typing async imports · Issue #11611 · microsoft/TypeScript · GitHub
Open Graph Title: Feature request: better support for typing async imports · Issue #11611 · microsoft/TypeScript
X Title: Feature request: better support for typing async imports · Issue #11611 · microsoft/TypeScript
Description: Currently, typescript has great support for ES6 style imports - e.g. import * as $ from "jquery"; function doSomething(): void { $("#foo")... } typescript is able to know that "jquery" here is whatever defines the jquery module, and $ ge...
Open Graph Description: Currently, typescript has great support for ES6 style imports - e.g. import * as $ from "jquery"; function doSomething(): void { $("#foo")... } typescript is able to know that "jquery" here is what...
X Description: Currently, typescript has great support for ES6 style imports - e.g. import * as $ from "jquery"; function doSomething(): void { $("#foo")... } typescript is able to know that &...
Mail addresses
notifications@github.com
notifications@github.com
notifications@github.com
Opengraph URL: https://github.com/microsoft/TypeScript/issues/11611
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Feature request: better support for typing async imports","articleBody":"Currently, typescript has great support for ES6 style imports - e.g.\n\n```\nimport * as $ from \"jquery\";\n\nfunction doSomething(): void {\n $(\"#foo\")...\n}\n```\n\ntypescript is able to know that `\"jquery\"` here is whatever defines the jquery module, and `$` gets the type associated with jquery's exports.\n\nHowever, if you try to async load code in typescript, it tends not to know the types. E.g. in AMD, the following code would make sense:\n\n```\nfunction doSomethingAsync(): void {\n require([\"jquery\"], function($) {\n $(\"#foo\")...\n });\n}\n```\n\nbut this leaves `$` with the type `any` (and noImplicitAny would complain about this). The options to handle this right now are:\n1) use definition files. Annoying because we end up with definition files for pure typescript, which presumably already declare all their types; it's a lot of unnecessary overhead.\n2) leave code untyped / make the `any` explicit.\n3) duplicate the types all over the place - e.g. here, declare the jquery type inline. This really isn't maintainable.\n4) don't do async imports. This is not really an option for large applications that care about performance.\n\nWhile I've describe the situation for AMD, my understanding is that other forms of async module loading (such as conditional `require()` calls in commonjs) suffer the same problems.\n\nnote: unlike #3100 I am neither suggesting new syntax, or that typescript should handle loading async code in any way; I would just like to see it be able to strongly type such code as it already handles ES6-style imports, and leave the implementation details of module loading to actual module loaders like node.js or requirejs.\n","author":{"url":"https://github.com/dgoldstein0","@type":"Person","name":"dgoldstein0"},"datePublished":"2016-10-14T04:48:10Z","url":"https://github.com/microsoft/TypeScript/issues/11611"}
| 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:f0227109-3882-445a-4e7f-75707a32bf72 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E1FA:24A0A:1E9F05:26638B:6B00F70E |
| html-safe-nonce | aa30e14a04cdacbc7bb7b67d5c385ef5ab9824d2c91621ce2d995671ab119ab1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMUZBOjI0QTBBOjFFOUYwNToyNjYzOEI6NkIwMEY3MEUiLCJ2aXNpdG9yX2lkIjoiNzg3MTYyNDQ5MzQ3NzcyMTg3MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 66dcf1cbac9eada11c1ef0ebb872f1d4f59c0186ff71b8784f6629fb5427dec1 |
| hovercard-subject-tag | issue:182962773 |
| 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/11611/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a5813dfbc3aedd3a1927e707698c8558e3876eee6fa4650ee4e581424490bc57/microsoft/TypeScript/issues/11611 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a5813dfbc3aedd3a1927e707698c8558e3876eee6fa4650ee4e581424490bc57/microsoft/TypeScript/issues/11611 |
| og:image:alt | Currently, typescript has great support for ES6 style imports - e.g. import * as $ from "jquery"; function doSomething(): void { $("#foo")... } typescript is able to know that "jquery" here is what... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dgoldstein0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| 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 | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width