typescript4j
typescript4j copied to clipboard
Error including files with relative paths
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.
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);