-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
When relatively importing a .d.ts
file in a declaration file, TypeScript loads a .ts
file instead
#58353
Comments
Yes. A See also #56412 (comment) and #15272. |
Also worth noting is that "Go to source definition" only works at all because the TS language service prefers to load the |
This is currently expected behavior, but I do think we should explore changing it. This happens to avoid loading your own output files as part of your input files, but it doesnβt make a lot of sense to do for files that you didnβt emit, e.g. declaration files in |
I"m confused how this project even builds. The inclusion of this Can we get a sample repo? |
If file is imported from |
I"ll set up a reproduction repo tomorrow |
Made a small reproduction, instructions are in the README: https://github.com/lucacasonato/typescript-issue-58353 |
Our workaround for this was emitting both the We"ll try again here, by only emitting |
π Search Terms
π Version & Regression Information
TypeScript 5.4.3
β― Playground Link
No response
π» Code
π Actual behavior
From the
walk.d.ts
file (referenced specified inpackage.json
"types"
conditional export), a type is imported from./_create_walk_entry.d.ts
. TypeScript however does not load./_create_walk_entry.d.ts
, but instead loads./_create_walk_entry.ts
(and then tries to check it) even though./_create_walk_entry.d.ts
exists. Why?The
.ts
files are included in the published package to enable "Go to source definition" for users. Is it really necessary to place all generated files into a separate directory?π Expected behavior
No
.ts
file to be loaded, because all specifiers (both in conditional exports, and in declaration files) reference.d.ts
files.This is especially the case because when
declaration: true
is specified, TypeScript will by default place.js
and.d.ts
directly next to the.ts
code. If you publish this to npm, it will not work.Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: