Repository navigation
Backlog
Description
Bug Report
- TypeScript versions:
7.0.2and7.1.0-beta(@typescript/typescript-win32-x64) - OS: Windows 11 Pro 10.0.26300 (Build 26300) with
LongPathsEnabled = 1
Summary
On Windows, native tsc.exe fails to resolve @types/* packages that are Windows directory junctions (error TS2688) when tsc.exe itself is installed under a long path (239+ characters). Running the same binary from a shorter path succeeds, and regular directories (non-junctions) also succeed from the long path.
This breaks Bazel builds using aspect_rules_js, which places tsc.exe under a deep output path and links node_modules/@types/* as Windows junctions.
tsc.exe does not include a longPathAware Windows application manifest, so Windows long path support is not enabled for the process even when LongPathsEnabled = 1 is set on the host.
Reproduction (PowerShell)
$root = "C:\Temp\ts_junction_repro"
cmd /c "rmdir /s /q `"$root`" 2>nul"
# 1. Create a minimal project with @types/foo as a Windows junction
New-Item -ItemType Directory -Force "$root\proj\node_modules\@types" | Out-Null
New-Item -ItemType Directory -Force "$root\real_foo" | Out-Null
'{"compilerOptions":{"types":["foo"],"noEmit":true},"files":["a.ts"]}' | Set-Content "$root\proj\tsconfig.json" -Encoding Ascii
'export const x = 1;' | Set-Content "$root\proj\a.ts" -Encoding Ascii
'{"name":"@types/foo","types":"index.d.ts"}' | Set-Content "$root\real_foo\package.json" -Encoding Ascii
'declare const foo: number;' | Set-Content "$root\real_foo\index.d.ts" -Encoding Ascii
cmd /c "mklink /J `"$root\proj\node_modules\@types\foo`" `"$root\real_foo`"" | Out-Null
# 2. Download @typescript/typescript-win32-x64@7.0.2
Invoke-WebRequest -Uri "https://registry.npmjs.org/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz" -OutFile "$root\pkg.tgz" -UseBasicParsing
# 3. Extract the same package into a short path and a long path
$short = "$root\short"
$long = "$root\" + ("a" * 55) + "\" + ("b" * 55) + "\" + ("c" * 55) + "\" + ("d" * 33)
New-Item -ItemType Directory -Force $short | Out-Null
New-Item -ItemType Directory -Force $long | Out-Null
tar -xzf "$root\pkg.tgz" -C $short --strip-components=1
tar -xzf "$root\pkg.tgz" -C $long --strip-components=1
# 4. Run both against the same project
& "$short\lib\tsc.exe" --project "$root\proj\tsconfig.json"
Write-Output "short ($(("$short\lib\tsc.exe").Length) chars) exit: $LASTEXITCODE"
& "$long\lib\tsc.exe" --project "$root\proj\tsconfig.json"
Write-Output "long ($(("$long\lib\tsc.exe").Length) chars) exit: $LASTEXITCODE"Actual Output
short (43 chars) exit: 0
error TS2688: Cannot find type definition file for 'foo'.
The file is in the program because:
Entry point of type library 'foo' specified in compilerOptions
long (239 chars) exit: 1
Expected Behavior
Both invocations should resolve @types/foo through the Windows junction and exit with 0.
Notes
- Invoking the long-path binary via a relative path (
.\tsc.exefrom$long\lib) still fails. - Reproduces on both
7.0.2and7.1.0-beta(built with Go1.26.4). - Possibly related to Go's Windows long path support (
golang/go#66560) andinternal/nativepathhandling near 248 characters.
Metadata
Metadata
Assignees
Labels
No labels
Activity