René's URL Explorer Experiment


Title: foo.ts is resolved before foo.d.ts even if the latter is in files[] · Issue #22208 · microsoft/TypeScript · GitHub

Open Graph Title: foo.ts is resolved before foo.d.ts even if the latter is in files[] · Issue #22208 · microsoft/TypeScript

X Title: foo.ts is resolved before foo.d.ts even if the latter is in files[] · Issue #22208 · microsoft/TypeScript

Description: Affects at least TS 2.7.2 and 2.6.2. This problem appears when compiling files separately, like we do under Bazel. Imagine this simple app src/lib.ts export const a = 1; src/main.ts import {a} from './lib'; Imagine lib.ts was compiled se...

Open Graph Description: Affects at least TS 2.7.2 and 2.6.2. This problem appears when compiling files separately, like we do under Bazel. Imagine this simple app src/lib.ts export const a = 1; src/main.ts import {a} from...

X Description: Affects at least TS 2.7.2 and 2.6.2. This problem appears when compiling files separately, like we do under Bazel. Imagine this simple app src/lib.ts export const a = 1; src/main.ts import {a} from...

Opengraph URL: https://github.com/microsoft/TypeScript/issues/22208

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"foo.ts is resolved before foo.d.ts even if the latter is in files[]","articleBody":"Affects at least TS 2.7.2 and 2.6.2. This problem appears when compiling files separately, like we do under Bazel.\r\n\r\nImagine this simple app\r\n\r\n`src/lib.ts`\r\n```\r\nexport const a = 1;\r\n```\r\n`src/main.ts`\r\n```\r\nimport {a} from './lib';\r\n```\r\n\r\nImagine `lib.ts` was compiled separately, so there already exists\r\n`dist/lib.d.ts`\r\n```\r\nexport declare const a = 1;\r\n```\r\n\r\nNow, I want to compile `main.ts` as a separate program. Given  `src/tsconfig.json`\r\n\r\n```\r\n{\r\n  \"compilerOptions\": {\r\n    \"rootDirs\": [\r\n      \".\",\r\n      \"../dist\"\r\n    ],\r\n    \"outDir\": \"../dist\",\r\n    \"declaration\": true\r\n  },\r\n\r\n  \"files\": [\r\n    \"main.ts\",\r\n    // lib was compiled separately\r\n    \"../dist/lib.d.ts\"\r\n  ]\r\n}\r\n```\r\n\r\nWe see that `lib.d.ts` is already in the program before resolution begins. However the compiler resolves the import statement to the `lib.ts` file instead, adding it to the program, and tries to emit on top of an input, so the error is\r\n\r\n```\r\n$ ./node_modules/.bin/tsc -p src\r\nerror TS5055: Cannot write file '/usr/local/google/home/alexeagle/Projects/repro_ts_resolving_ts/dist/lib.d.ts' because it would overwrite input file.\r\n```\r\n\r\nOkay, we didn't want `lib.ts` in the program, so we should just use `--noResolve` to prevent that, but it's also broken:\r\n```\r\n$ ./node_modules/.bin/tsc -p src --noResolve --traceResolution\r\n======== Resolving module './lib' from '/usr/local/google/home/alexeagle/Projects/repro_ts_resolving_ts/src/main.ts'. ========\r\nModule resolution kind is not specified, using 'NodeJs'.\r\n'rootDirs' option is set, using it to resolve relative module name './lib'.\r\nChecking if '/usr/local/google/home/alexeagle/Projects/repro_ts_resolving_ts/src/' is the longest matching prefix for '/usr/local/google/home/alexeagle/Projects/repro_ts_resolving_ts/src/lib' - 'true'.\r\nChecking if '/usr/local/google/home/alexeagle/Projects/repro_ts_resolving_ts/dist/' is the longest matching prefix for '/usr/local/google/home/alexeagle/Projects/repro_ts_resolving_ts/src/lib' - 'false'.\r\nLongest matching prefix for '/usr/local/google/home/alexeagle/Projects/repro_ts_resolving_ts/src/lib' is '/usr/local/google/home/alexeagle/Projects/repro_ts_resolving_ts/src/'.\r\nLoading 'lib' from the root dir '/usr/local/google/home/alexeagle/Projects/repro_ts_resolving_ts/src/', candidate location '/usr/local/google/home/alexeagle/Projects/repro_ts_resolving_ts/src/lib'.\r\nLoading module as file / folder, candidate module location '/usr/local/google/home/alexeagle/Projects/repro_ts_resolving_ts/src/lib', target file type 'TypeScript'.\r\nFile '/usr/local/google/home/alexeagle/Projects/repro_ts_resolving_ts/src/lib.ts' exist - use it as a name resolution result.\r\n======== Module name './lib' was successfully resolved to '/usr/local/google/home/alexeagle/Projects/repro_ts_resolving_ts/src/lib.ts'. ========\r\nsrc/main.ts(1,17): error TS2307: Cannot find module './lib'.\r\n```\r\n\r\nSo far our workaround at Google is one of:\r\n- use Bazel sandboxing to make the inputs appear in different places\r\n- use our own custom compiler which elides any emit to files we don't expect\r\n\r\nHowever under Bazel we sometimes cannot sandbox (eg. on Windows) and cannot use our custom compiler (eg. when we are compiling it)\r\nso we are stuck.\r\n\r\nI found that `ts.CompilerOptions.suppressOutputPathCheck` could be a workaround, but `tsc` doesn't allow that flag from the command line or tsconfig.json  (it's not in `optionDeclarations` in `commandLineParser.ts`)","author":{"url":"https://github.com/alexeagle","@type":"Person","name":"alexeagle"},"datePublished":"2018-02-27T19:37:45Z","url":"https://github.com/microsoft/TypeScript/issues/22208"}

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:93d9a196-57c9-135f-7301-f748548c9a33
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id8C50:26981B:21588F:2DE98A:6B0451C3
html-safe-nonced4bde6807c838211c0529870a267cade2c7d05bf1a586e8bf2a06ac91ea85888
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QzUwOjI2OTgxQjoyMTU4OEY6MkRFOThBOjZCMDQ1MUMzIiwidmlzaXRvcl9pZCI6IjgxMjE2OTM1ODE2NzI2NTczMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac6f265c030fe2788ead89a9d88ed1771b5910f14fca63e298465ece744a11b630
hovercard-subject-tagissue:300764867
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/22208/issue_layout
twitter:imagehttps://opengraph.githubassets.com/9a0dc9536c2cdd5c0e62820d5b9a8827aa826d3afe7bd51817ed5f4f3f1beac7/microsoft/TypeScript/issues/22208
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/9a0dc9536c2cdd5c0e62820d5b9a8827aa826d3afe7bd51817ed5f4f3f1beac7/microsoft/TypeScript/issues/22208
og:image:altAffects at least TS 2.7.2 and 2.6.2. This problem appears when compiling files separately, like we do under Bazel. Imagine this simple app src/lib.ts export const a = 1; src/main.ts import {a} from...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamealexeagle
hostnamegithub.com
expected-hostnamegithub.com
None910ca0e260cfec6aff11407d8dc6a0d3a4cd381a2ec9ada56627b063426892a0
turbo-cache-controlno-preview
go-importgithub.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git
octolytics-dimension-user_id6154722
octolytics-dimension-user_loginmicrosoft
octolytics-dimension-repository_id20929025
octolytics-dimension-repository_nwomicrosoft/TypeScript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id20929025
octolytics-dimension-repository_network_root_nwomicrosoft/TypeScript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasee086f9b7e88322eb2b41885a6ad425b215737fa5
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/microsoft/TypeScript/issues/22208#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F22208
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmicrosoft%2FTypeScript%2Fissues%2F22208
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=microsoft%2FTypeScript
Reloadhttps://github.com/microsoft/TypeScript/issues/22208
Reloadhttps://github.com/microsoft/TypeScript/issues/22208
Reloadhttps://github.com/microsoft/TypeScript/issues/22208
microsofthttps://github.com/microsoft
TypeScripthttps://github.com/microsoft/TypeScript
Codehttps://github.com/microsoft/TypeScript
Issues5k (5k)https://github.com/microsoft/TypeScript/issues
Pull requests320 (320)https://github.com/microsoft/TypeScript/pulls
Actionshttps://github.com/microsoft/TypeScript/actions
Projectshttps://github.com/microsoft/TypeScript/projects
Wikihttps://github.com/microsoft/TypeScript/wiki
Security and qualityhttps://github.com/microsoft/TypeScript/security
Insightshttps://github.com/microsoft/TypeScript/insights
https://github.com/microsoft/TypeScript
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/22208
New issuehttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/22208
foo.ts is resolved before foo.d.ts even if the latter is in files[]https://github.com/microsoft/TypeScript/issues/22208#top
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
Backloghttps://github.com/microsoft/TypeScript/milestone/29
https://github.com/alexeagle
Alex Eagle (alexeagle)https://github.com/alexeagle
on Feb 27, 2018https://github.com/microsoft/TypeScript/issues/22208#issue-300764867
https://github.com/alexeagle
Alex Eagle (alexeagle)https://github.com/alexeagle
on Feb 27, 2018https://github.com/microsoft/TypeScript/issues/22208#issuecomment-369040111
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Feb 27, 2018https://github.com/microsoft/TypeScript/issues/22208#issuecomment-369057813
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
https://github.com/alexeagle
Alex Eagle (alexeagle)https://github.com/alexeagle
on Feb 28, 2018https://github.com/microsoft/TypeScript/issues/22208#issuecomment-369315448
https://github.com/evmar
Evan Martin (evmar)https://github.com/evmar
on Mar 1, 2018https://github.com/microsoft/TypeScript/issues/22208#issuecomment-369430738
Alex Eagle (alexeagle)https://github.com/alexeagle
on Mar 1, 2018https://github.com/microsoft/TypeScript/issues/22208#event-1499280164
Workaround for microsoft/TypeScript#22208https://github.com/bazelbuild/rules_typescript/commit/65cc4da75bcd4cb88f7dcd621da17afc29c80ff3
microsoft/TypeScript#22208https://github.com/microsoft/TypeScript/issues/22208
65cc4dahttps://github.com/bazelbuild/rules_typescript/commit/65cc4da75bcd4cb88f7dcd621da17afc29c80ff3
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Mar 1, 2018https://github.com/microsoft/TypeScript/issues/22208#issuecomment-369708582
https://github.com/mhegazy
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
on Mar 1, 2018https://github.com/microsoft/TypeScript/issues/22208#issuecomment-369709175
https://github.com/alexeagle
Alex Eagle (alexeagle)https://github.com/alexeagle
on Mar 1, 2018https://github.com/microsoft/TypeScript/issues/22208#issuecomment-369731704
https://github.com/mprobst
Martin Probst (mprobst)https://github.com/mprobst
on Mar 28, 2018https://github.com/microsoft/TypeScript/issues/22208#issuecomment-376879283
Mohamed Hegazy (mhegazy)https://github.com/mhegazy
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
on Mar 28, 2018https://github.com/microsoft/TypeScript/issues/22208#event-1546052717
Alex Eagle (alexeagle)https://github.com/alexeagle
on Apr 26, 2018https://github.com/microsoft/TypeScript/issues/22208#event-1597404542
Further restrict the non-hermetic reads of tsc_wrapped.https://github.com/bazelbuild/rules_typescript/commit/d1c107e4c62ced467fa17db0e56de3dc20001b72
d1c107ehttps://github.com/bazelbuild/rules_typescript/commit/d1c107e4c62ced467fa17db0e56de3dc20001b72
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
help wantedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22help%20wanted%22
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
In DiscussionNot yet reached consensushttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22In%20Discussion%22
on Oct 9, 2018https://github.com/microsoft/TypeScript/issues/22208#event-1894186159
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Futurehttps://github.com/microsoft/TypeScript/milestone/29
on Oct 9, 2018https://github.com/microsoft/TypeScript/issues/22208#event-1894186197
https://github.com/rkirov
Rado Kirov (rkirov)https://github.com/rkirov
on Mar 28, 2020https://github.com/microsoft/TypeScript/issues/22208#issuecomment-605370981
Ryan Cavanaugh (@RyanCavanaugh)https://github.com/RyanCavanaugh
#22208 (comment)https://github.com/microsoft/TypeScript/issues/22208#issuecomment-376879283
https://github.com/manughub
manughubhttps://github.com/manughub
on Apr 8, 2020https://github.com/microsoft/TypeScript/issues/22208#issuecomment-611166967
reproduction of the issuehttps://github.com/manughub/ts22208-repro
Alex Eagle (alexeagle)https://github.com/alexeagle
on Oct 17, 2020https://github.com/microsoft/TypeScript/issues/22208#event-3889746940
Workaround for microsoft/TypeScript#22208https://github.com/alexeagle/rules_nodejs/commit/9a693bb7e6748905fc983aa467a73880e2946fb9
microsoft/TypeScript#22208https://github.com/microsoft/TypeScript/issues/22208
9a693bbhttps://github.com/alexeagle/rules_nodejs/commit/9a693bb7e6748905fc983aa467a73880e2946fb9
Further restrict the non-hermetic reads of tsc_wrapped.https://github.com/alexeagle/rules_nodejs/commit/30d28943efa6ea3880879bcf7f11a3d455fcb4a6
30d2894https://github.com/alexeagle/rules_nodejs/commit/30d28943efa6ea3880879bcf7f11a3d455fcb4a6
Workaround for microsoft/TypeScript#22208https://github.com/alexeagle/rules_nodejs/commit/3efc8ef6f85377c6c4b2a5fc9e35434a426cd56a
microsoft/TypeScript#22208https://github.com/microsoft/TypeScript/issues/22208
3efc8efhttps://github.com/alexeagle/rules_nodejs/commit/3efc8ef6f85377c6c4b2a5fc9e35434a426cd56a
Further restrict the non-hermetic reads of tsc_wrapped.https://github.com/alexeagle/rules_nodejs/commit/a9363ac560074666bb01fd2aa2c9dd00a711015e
a9363achttps://github.com/alexeagle/rules_nodejs/commit/a9363ac560074666bb01fd2aa2c9dd00a711015e
Nicholas Paun (npaun)https://github.com/npaun
on Jul 31, 2025https://github.com/microsoft/TypeScript/issues/22208#event-18926695054
macOS CI: use sandbox for building even if we can't use it for testshttps://github.com/cloudflare/workerd/commit/3bb3246fd75e80676db977b67113065825f7da0d
3bb3246https://github.com/cloudflare/workerd/commit/3bb3246fd75e80676db977b67113065825f7da0d
macOS CI: use sandbox for building even if we can't use it for tests (#…https://github.com/cloudflare/workerd/commit/a758f808a8327f452f46ec4838a81cb4fa6540b7
#…https://github.com/cloudflare/workerd/pull/4656
a758f80https://github.com/cloudflare/workerd/commit/a758f808a8327f452f46ec4838a81cb4fa6540b7
Josh Howard (joshthoward)https://github.com/joshthoward
on Aug 7, 2025https://github.com/microsoft/TypeScript/issues/22208#event-19035992625
macOS CI: use sandbox for building even if we can't use it for tests (#…https://github.com/cloudflare/workerd/commit/d8c8e910a76154d2122a19deffb3787519fec8a6
#…https://github.com/cloudflare/workerd/pull/4656
d8c8e91https://github.com/cloudflare/workerd/commit/d8c8e910a76154d2122a19deffb3787519fec8a6
Ryan Cavanaugh (RyanCavanaugh)https://github.com/RyanCavanaugh
Help Wantedhttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Help%20Wanted%22
on Nov 10, 2026https://github.com/microsoft/TypeScript/issues/22208#event-35721744331
Sign up for freehttps://github.com/signup?return_to=https://github.com/microsoft/TypeScript/issues/22208
Sign in to commenthttps://github.com/login?return_to=https://github.com/microsoft/TypeScript/issues/22208
CommittedThe team has roadmapped this issuehttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Committed%22
SuggestionAn idea for TypeScripthttps://github.com/microsoft/TypeScript/issues?q=state%3Aopen%20label%3A%22Suggestion%22
BacklogNo due datehttps://github.com/microsoft/TypeScript/milestone/29
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.