Skip to content

Symlinks not resolved for /// <reference path="..." /> #9091

@alexeagle

Description

@alexeagle

TypeScript Version:

nightly (1.9.0-dev)

Code

$ ls -alF
 a/
 project/
 symlink -> a/
$ cat a/one.ts 
import './zone';
$ cat a/zone.d.ts
declare type ZoneType = {a:string};
declare const Zone: ZoneType;
$ cat project/tsconfig.json
{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "noEmit": true,
        "traceResolution": true
    }
}
$ cat project/deps.d.ts
///<reference path="../symlink/zone.d.ts"/>
///<reference path="../symlink/one.ts"/>

Expected behavior:
There are two ways the program may import zone.d.ts, either by resolving symlinks to ../a/zone or by using the path provided ../symlink/zone. In order to treat these as the same file, TypeScript needs to use the same path internally.

Actual behavior:
One case resolves the symlink and the other does not, causing the declarations in the file to conflict with themselves:

$ tsc -p project
======== Resolving module './zone' from '/usr/local/google/home/alexeagle/repro_pathmapping_zone/symlink/one.ts'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module as file / folder, candidate module location '/usr/local/google/home/alexeagle/repro_pathmapping_zone/symlink/zone'.
File '/usr/local/google/home/alexeagle/repro_pathmapping_zone/symlink/zone.ts' does not exist.
File '/usr/local/google/home/alexeagle/repro_pathmapping_zone/symlink/zone.tsx' does not exist.
File '/usr/local/google/home/alexeagle/repro_pathmapping_zone/symlink/zone.d.ts' exist - use it as a name resolution result.
Resolving real path for '/usr/local/google/home/alexeagle/repro_pathmapping_zone/symlink/zone.d.ts', result '/usr/local/google/home/alexeagle/repro_pathmapping_zone/a/zone.d.ts'
======== Module name './zone' was successfully resolved to '/usr/local/google/home/alexeagle/repro_pathmapping_zone/a/zone.d.ts'. ========
a/zone.d.ts(1,14): error TS2300: Duplicate identifier 'ZoneType'.
a/zone.d.ts(2,15): error TS2451: Cannot redeclare block-scoped variable 'Zone'.
symlink/zone.d.ts(1,14): error TS2300: Duplicate identifier 'ZoneType'.
symlink/zone.d.ts(2,15): error TS2451: Cannot redeclare block-scoped variable 'Zone'.

with @vikerman

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Module ResolutionHow to turn an import specifier into a .d.ts, .ts, or .js file on disk

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions