-
Notifications
You must be signed in to change notification settings - Fork 12.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pulling in ambient types through triple slash directive stopped working when exports field present on package.json #46860
Labels
Fix Available
A PR has been opened for this issue
Needs Investigation
This issue needs a team member to investigate its status.
Milestone
Comments
dummdidumm
added a commit
to sveltejs/svelte
that referenced
this issue
Nov 18, 2021
This will be needed when TS adds the new node module resolution algorithm. It also solves microsoft/TypeScript#46860 on our end.
This was referenced Nov 18, 2021
dummdidumm
added a commit
to sveltejs/svelte
that referenced
this issue
Nov 19, 2021
This will be needed when TS adds the new node module resolution algorithm. It also solves microsoft/TypeScript#46860 on our end. Closes #6939
thetutlage
added a commit
to adonisjs/core
that referenced
this issue
Nov 21, 2021
Our lovely TypeScript is finding every possible way to break things on every release. I cannot find any documentation on "export maps" behavior, except these issues microsoft/TypeScript#46860 microsoft/TypeScript#46334
RyanCavanaugh
added
the
Needs Investigation
This issue needs a team member to investigate its status.
label
Nov 22, 2021
hakula139
added a commit
to hakula139/careecuz-frontend
that referenced
this issue
Dec 22, 2021
hakula139
added a commit
to hakula139/vue-ts-app-template
that referenced
this issue
Dec 22, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Fix Available
A PR has been opened for this issue
Needs Investigation
This issue needs a team member to investigate its status.
Bug Report
π Search Terms
tripleslash ambient types
π Version & Regression Information
β― Playground Link
Not possible to show in the playground
π» Code
global.d.ts
/// <reference types="svelte" />
π Actual behavior
Since 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 theirpackage.json
, but notypes
field insideexports
.π Expected behavior
Referencing types via triple slash directives should pull in their ambient types into the global scope
Steps to reproduce
This 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
.npx degit sveltejs/template svelte-app
cd svelte-app/ && node scripts/setupTypeScript.js
- this converts the template to using TSpackage.json
pin thesvelte
version to3.44.1
(the last version where this occurs, we since added a fix on our side, but I still think this a TS bug)npm install
main.ts
--> bug:import App from './Apps.svelte';
has an error because the triple slash directive inglobal.d.ts
doesn't workIf I change the triple slash directive in
global.d.ts
to/// <reference path="../node_modules/svelte/types/runtime/index.d.ts" />
it works. That path reference is what thetypes
field in thepackage.json
of Svelte resolves to, so I would expect/// <reference types="svelte" />
to work.My 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 theexports
in Svelte'spackage.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/// <reference types="svelte" />
iftypes
is part of theexports
inpackage.json
.I guess this not only impacts the Svelte starter template but every package which has
exports
withouttypes
in it and wants to support loading definitions into the global scope through tripleslash directives.The text was updated successfully, but these errors were encountered: