Title: Pulling in ambient types through triple slash directive stopped working when exports field present on package.json · Issue #46860 · microsoft/TypeScript · GitHub
Open Graph Title: Pulling in ambient types through triple slash directive stopped working when exports field present on package.json · Issue #46860 · microsoft/TypeScript
X Title: Pulling in ambient types through triple slash directive stopped working when exports field present on package.json · Issue #46860 · microsoft/TypeScript
Description: Bug Report 🔎 Search Terms tripleslash ambient types 🕗 Version & Regression Information This changed between the latest version o 4.4 and 4.5.2 ⏯ Playground Link Not possible to show in the playground 💻 Code global.d.ts /// Open Graph Description: Bug Report 🔎 Search Terms tripleslash ambient types 🕗 Version & Regression Information This changed between the latest version o 4.4 and 4.5.2 ⏯ Playground Link Not possible to show in the playgrou...
X Description: Bug Report 🔎 Search Terms tripleslash ambient types 🕗 Version & Regression Information This changed between the latest version o 4.4 and 4.5.2 ⏯ Playground Link Not possible to show in the play...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/46860
X: @github
Domain: github.com
Links:
Viewport: width=device-width
Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Pulling in ambient types through triple slash directive stopped working when exports field present on package.json","articleBody":"# Bug Report\r\n\r\n### 🔎 Search Terms\r\n\r\ntripleslash ambient types\r\n\r\n### 🕗 Version & Regression Information\r\n\r\n- This changed between the latest version o 4.4 and 4.5.2\r\n\r\n### ⏯ Playground Link\r\n\r\nNot possible to show in the playground\r\n\r\n### 💻 Code\r\n`global.d.ts`\r\n```ts\r\n/// \u003creference types=\"svelte\" />\r\n```\r\n\r\n### 🙁 Actual behavior\r\n\r\nSince 4.5 referencing types via triple slash directives in an ambient module to pull in other ambient types into the global scope stopped working when the package whose types should be pulled in has `exports` defined in their `package.json`, but no `types` field inside `exports`. \r\n\r\n### 🙂 Expected behavior\r\n\r\nReferencing types via triple slash directives should pull in their ambient types into the global scope\r\n\r\n### Steps to reproduce\r\n\r\nThis is reproducible using the Svelte starter template which uses this technique to tell TypeScript to treat any file import ending with `.svelte` as valid, resolving it to an ambient module named `*.svelte`.\r\n\r\n1. Clone https://github.com/sveltejs/template, for example through `npx degit sveltejs/template svelte-app`\r\n2. `cd svelte-app/ && node scripts/setupTypeScript.js` - this converts the template to using TS\r\n3. In the `package.json` pin the `svelte` version to `3.44.1` (the last version where this occurs, we since added a fix on our side, but I still think this a TS bug)\r\n4. `npm install`\r\n5. Open project in VS Code and set TS to use the workspace TS version\r\n6. Open `main.ts` --> bug: `import App from './Apps.svelte';` has an error because the triple slash directive in `global.d.ts` doesn't work\r\n\r\nIf I change the triple slash directive in `global.d.ts` to `/// \u003creference path=\"../node_modules/svelte/types/runtime/index.d.ts\" />` it works. That path reference is what the `types` field in the `package.json` of Svelte resolves to, so I would expect `/// \u003creference types=\"svelte\" />` to work.\r\n\r\nMy guess is that this is a side effect of the new Node12 mode which was part of the 4.5 beta releases but was then pulled out of the final release. With that new mode it would be expected to have a corresponding `types` entry as part of the `exports` in Svelte's `package.json`, but since that new resolution isn't used I would expect the types to get resolved like in 4.4 and downwards. In fact, I just tested this out and it indeed works in 4.5 using `/// \u003creference types=\"svelte\" />` if `types` is part of the `exports` in `package.json`.\r\n\r\nI guess this not only impacts the Svelte starter template but every package which has `exports` without `types` in it and wants to support loading definitions into the global scope through tripleslash directives.","author":{"url":"https://github.com/dummdidumm","@type":"Person","name":"dummdidumm"},"datePublished":"2021-11-18T22:06:28Z","url":"https://github.com/microsoft/TypeScript/issues/46860"}
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:00a34537-96b4-644c-191f-14fae0a1c7ea current-catalog-service-hash 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 request-id CBD0:27D3AD:D0C100:10A0D19:6B010090 html-safe-nonce 48d2328cfa3da345d01af6b833c07493ddd09806103dae28e81fcffad291f1e8 visitor-payload eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQkQwOjI3RDNBRDpEMEMxMDA6MTBBMEQxOTo2QjAxMDA5MCIsInZpc2l0b3JfaWQiOiI0NTM2MDE5NzczMTg3NzUyMDgwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= visitor-hmac 59517bacd391501467495e90cf4f15a82246b922a7166f315171b12d7b747f61 hovercard-subject-tag issue:1057867585 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/46860/issue_layout twitter:image https://opengraph.githubassets.com/5d96bdacd13adacc9494007af5094c16eaad5a33ebfea73c3ae5e955a2cfce77/microsoft/TypeScript/issues/46860 twitter:card summary_large_image og:image https://opengraph.githubassets.com/5d96bdacd13adacc9494007af5094c16eaad5a33ebfea73c3ae5e955a2cfce77/microsoft/TypeScript/issues/46860 og:image:alt Bug Report 🔎 Search Terms tripleslash ambient types 🕗 Version & Regression Information This changed between the latest version o 4.4 and 4.5.2 ⏯ Playground Link Not possible to show in the playgrou... og:image:width 1200 og:image:height 600 og:site_name GitHub og:type object og:author:username dummdidumm 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
URLs of crawlers that visited me.