Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Error including files with relative paths #13

Open
ruediste opened this issue Sep 10, 2015 · 1 comment
Open

Error including files with relative paths #13

ruediste opened this issue Sep 10, 2015 · 1 comment

Comments

@ruediste
Copy link

When a .ts file contains a reference in the form

///<reference path="../es6-promise/es6-promise.d.ts"/>

the referenced file is looked up relative to the base path of the CompilationContext instead of the current source.

@ruediste
Copy link
Author

The following patch in typescript.compile.js fixed the issue, however I think the logic is better placed in the CompilationContext

Line 74:      var fileReferencesInSource = TypeScript.getReferencedFiles(sourceToParse.path, code);

        // patch start
        for( var i = 0; i < fileReferencesInSource.length; i++ ){
            var ref = fileReferencesInSource[i];
            var idx=sourceToParse.path.lastIndexOf('/');
            if (idx > 0)
              // prepend the path of the source file to the include
              ref.path = new java.lang.String(sourceToParse.path.substring(0,idx)+'/' + ref.path);
        }
        // patch end

        var referencedSourceUnits = compilationContext.resolveFiles(fileReferencesInSource);

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant