File tree 2 files changed +12
-5
lines changed 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 1
1
import * as ts from 'typescript' ;
2
2
import * as _ts from '../../ts-internal' ;
3
- import * as Path from 'path' ;
4
3
5
4
import { ConverterComponent } from '../components' ;
6
- import { normalizePath } from '../../utils/fs' ;
7
5
8
6
/**
9
7
* Return code of ts.sys.readFile when the file encoding is unsupported.
@@ -52,9 +50,8 @@ export class CompilerHost extends ConverterComponent implements ts.CompilerHost
52
50
* @returns The full path of the default library.
53
51
*/
54
52
getDefaultLibFileName ( options : ts . CompilerOptions ) : string {
55
- const lib = this . owner . getDefaultLib ( ) ;
56
- const path = _ts . getDirectoryPath ( normalizePath ( require . resolve ( 'typescript' ) ) ) ;
57
- return Path . join ( path , lib ) ;
53
+ const libLocation = _ts . getDirectoryPath ( _ts . normalizePath ( ts . sys . getExecutingFilePath ( ) ) ) ;
54
+ return _ts . combinePaths ( libLocation , ts . getDefaultLibFileName ( options ) ) ;
58
55
}
59
56
60
57
getDirectories ( path : string ) : string [ ] {
Original file line number Diff line number Diff line change @@ -56,6 +56,16 @@ export function getDirectoryPath() {
56
56
return tsany . getDirectoryPath . apply ( this , arguments ) ;
57
57
}
58
58
59
+ // https://github.com/Microsoft/TypeScript/blob/v2.2.1/src/compiler/core.ts#L1418
60
+ export function normalizePath ( path : string ) : string {
61
+ return tsany . normalizePath ( path ) ;
62
+ }
63
+
64
+ // https://github.com/Microsoft/TypeScript/blob/v2.2.1/src/compiler/core.ts#L1628
65
+ export function combinePaths ( path1 : string , path2 : string ) : string {
66
+ return tsany . combinePaths ( path1 , path2 ) ;
67
+ }
68
+
59
69
/**
60
70
* These functions are in "utilities" and are marked as @internal:
61
71
* https://github.com/Microsoft/TypeScript/blob/v2.1.4/src/compiler/utilities.ts#L3-L4
You can’t perform that action at this time.
0 commit comments