René's URL Explorer Experiment


Title: Improve portability of resolution-mode assertions automatically emitted in `nodenext` · Issue #55579 · microsoft/TypeScript · GitHub

Open Graph Title: Improve portability of resolution-mode assertions automatically emitted in `nodenext` · Issue #55579 · microsoft/TypeScript

X Title: Improve portability of resolution-mode assertions automatically emitted in `nodenext` · Issue #55579 · microsoft/TypeScript

Description: In the last week, I’ve gotten two separate requests for help with solving an issue where a resolution-mode assertion in a triple-slash reference: /// was automatically inserted into a ...

Open Graph Description: In the last week, I’ve gotten two separate requests for help with solving an issue where a resolution-mode assertion in a triple-slash reference: /// \r\n```\r\n\r\nwas automatically inserted into a declaration file. The implementation file was an ES module that referenced a global defined in `chai`, which only ships as a CommonJS module. Presumably, the resolution-mode assertion gets added in declaration emit to increase the likelihood that, if the user installs a version of `chai` that contains separate ESM and CJS types, the ESM-format .d.ts file here will still resolve to the CJS types, as it did when it was created by the library’s compilation. (Note that if the user does have the same version of `chai` that the library had during compilation, the resolution-mode assertion will not actually be needed.)\r\n\r\nThe reason this was an issue for the two folks who reached out to me was that some of their users who consumed these declaration files were using `--moduleResolution bundler` or maybe even `--moduleResolution node10`, and consequently got the error:\r\n\r\n```\r\nerror TS1452: 'resolution-mode' assertions are only supported when `moduleResolution` is `node16` or `nodenext`.\r\n```\r\n\r\nI feel pretty confident that non-node16/nodenext modes could simply ignore these assertions when they occur in declaration files. While we can’t guarantee that users in other modes will resolve these references the same way the library did, this is no different from any `import` statement the user wrote, or indeed any `import()` type automatically inserted by the declaration emitter.\r\n\r\nMaybe better, we could also consider supporting resolution-mode assertions and the way they affect conditional package.json `\"exports\"` lookups in every `moduleResolution` mode in type reference directive lookups. They don’t reflect a runtime module resolution feature, so it feels like all we should care about is doing our best to resolve to the same global types in every `moduleResolution` mode.\r\n\r\nIt should be noted that in the meantime, a workaround for library authors is to manually write a `/// \u003creference types=\"chai\" />` with no resolution-mode assertion in the implementation file that generated the reference that caused the problem.","author":{"url":"https://github.com/andrewbranch","@type":"Person","name":"andrewbranch"},"datePublished":"2023-08-30T21:10:30Z","url":"https://github.com/microsoft/TypeScript/issues/55579"}


react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:be2cdc58-85a4-4ffb-ba9d-853f19b29cbf
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id9E6A:24A0A:36EAB5:44D597:6B00FEF5
html-safe-nonce95102ae0b25be6da8df20fd7b5be0089454c5b4ed590f34db7ee3aac80e928c0
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RTZBOjI0QTBBOjM2RUFCNTo0NEQ1OTc6NkIwMEZFRjUiLCJ2aXNpdG9yX2lkIjoiNjIxMTI0MDY2NzEzNDM2MTMzMyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac9021d9873e9464ac8abc65d7fc1c3b62d3c53bc762e345604d47a8ab2c7125a0
hovercard-subject-tagissue:1874372482
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/55579/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b381ff122492e53948e1b640c3fe4dfddf1c91df60155b0514deaa67d6f077f8/microsoft/TypeScript/issues/55579
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b381ff122492e53948e1b640c3fe4dfddf1c91df60155b0514deaa67d6f077f8/microsoft/TypeScript/issues/55579
og:image:altIn the last week, I’ve gotten two separate requests for help with solving an issue where a resolution-mode assertion in a triple-slash reference: ///