Title: Improve declare module wildcards so that they can match parts of a path more like a glob · Issue #38638 · microsoft/TypeScript · GitHub
Open Graph Title: Improve declare module wildcards so that they can match parts of a path more like a glob · Issue #38638 · microsoft/TypeScript
X Title: Improve declare module wildcards so that they can match parts of a path more like a glob · Issue #38638 · microsoft/TypeScript
Description: Search Terms global module match glob path Suggestion Improve the declare module wildcards so that they can be used multiple times in a path and they can match multiple parts of it. Use Cases In the project I am currently working on we m...
Open Graph Description: Search Terms global module match glob path Suggestion Improve the declare module wildcards so that they can be used multiple times in a path and they can match multiple parts of it. Use Cases In th...
X Description: Search Terms global module match glob path Suggestion Improve the declare module wildcards so that they can be used multiple times in a path and they can match multiple parts of it. Use Cases In th...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/38638
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Improve declare module wildcards so that they can match parts of a path more like a glob","articleBody":"\u003c!-- 🚨 STOP 🚨 𝗦𝗧𝗢𝗣 🚨 𝑺𝑻𝑶𝑷 🚨\r\n\r\nHalf of all issues filed here are duplicates, answered in the FAQ, or not appropriate for the bug tracker.\r\n\r\nPlease help us by doing the following steps before logging an issue:\r\n * Search: https://github.com/Microsoft/TypeScript/search?type=Issues\r\n * Read the FAQ, especially the \"Common Feature Requests\" section: https://github.com/Microsoft/TypeScript/wiki/FAQ\r\n\r\n-->\r\n\r\n## Search Terms\r\n\r\nglobal module match glob path\r\n\r\n## Suggestion\r\n\r\nImprove the declare module wildcards so that they can be used multiple times in a path and they can match multiple parts of it.\r\n\r\n## Use Cases\r\n\r\n\u003c!--\r\nWhat do you want to use this for?\r\nWhat shortcomings exist with current approaches?\r\n-->\r\n\r\nIn the project I am currently working on we make a distinction between images and icons:\r\n* icons are usually small in size and used multiple times so we store them as SVG and put them in a SVG sprite with the help of [external-svg-sprite-loader](https://github.com/Karify/external-svg-sprite-loader).\r\n* images are usually bigger in size and used only once so we store them as well as SVGs but do not put them in a sprite.\r\n\r\nSince SVG imports are not recognized by TypeScript I want to create a global module declaration that targets all icon imports and another that targets all image imports. However, based on the feedback I got in this [StackOverflow issue](https://stackoverflow.com/questions/61816777/how-to-create-a-typescript-module-that-matches-complex-paths), it doesn't seem to be possible to do this since the support of wildcards in module paths seems to be very limited.\r\n\r\n## Examples\r\n\r\nThis is an example of what I would like to be able to do:\r\n\r\n```typescript\r\ndeclare module '@my/**/icons/**/*.svg' {\r\n type IconType = { viewBox: string, symbol: string };\r\n\r\n const icon: IconType;\r\n export = icon;\r\n}\r\n\r\ndeclare module '@my/**/images/**/*.svg' {\r\n const url: string;\r\n export = url;\r\n}\r\n```\r\n\r\n## Checklist\r\n\r\nMy suggestion meets these guidelines:\r\n\r\n* [ ] This wouldn't be a breaking change in existing TypeScript/JavaScript code\r\n* [ ] This wouldn't change the runtime behavior of existing JavaScript code\r\n* [ ] This could be implemented without emitting different JS based on the types of the expressions\r\n* [ ] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)\r\n* [ ] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).\r\n","author":{"url":"https://github.com/bensampaio","@type":"Person","name":"bensampaio"},"datePublished":"2020-05-18T15:41:45Z","url":"https://github.com/microsoft/TypeScript/issues/38638"}
| 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:ac5576e3-5700-18fd-24d8-c8e0533f2261 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C320:34CAB:A2756B:D081C2:6B00F5A4 |
| html-safe-nonce | bfb1562d904a30e8c212be308ba9a6118052ce00c01a94b659aea38191f27749 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzIwOjM0Q0FCOkEyNzU2QjpEMDgxQzI6NkIwMEY1QTQiLCJ2aXNpdG9yX2lkIjoiNzM0NjczODI1MzkyNTUxMjYxMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | bbc4a83ca7031f72a729b2c78f0e564756ed56d3f940976c3d89c20b8b03b140 |
| hovercard-subject-tag | issue:620311164 |
| 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/38638/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eda039bd32e7d24254a90dd03140d625e560f56e3e598521a844fffb8ac12c9f/microsoft/TypeScript/issues/38638 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eda039bd32e7d24254a90dd03140d625e560f56e3e598521a844fffb8ac12c9f/microsoft/TypeScript/issues/38638 |
| og:image:alt | Search Terms global module match glob path Suggestion Improve the declare module wildcards so that they can be used multiple times in a path and they can match multiple parts of it. Use Cases In th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | bensampaio |
| hostname | github.com |
| expected-hostname | github.com |
| None | e208d86428ec00a57ade75058166297440e8128a01e5287c31a53dc042bbf187 |
| 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 | 7dafd017fb7809a839c443dba08622af38e63c09 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width