@@ -13,10 +13,10 @@ namespace ts {
13
13
const emptyArray : any [ ] = [ ] ;
14
14
15
15
const defaultLibrarySearchPaths = [
16
- './' ,
17
- './ typings/' ,
18
- './ node_modules/' ,
19
- './ node_modules/@types/' ,
16
+ "" ,
17
+ " typings/" ,
18
+ " node_modules/" ,
19
+ " node_modules/@types/" ,
20
20
] ;
21
21
22
22
export const version = "1.9.0" ;
@@ -1489,13 +1489,12 @@ namespace ts {
1489
1489
skipDefaultLib = skipDefaultLib || file . hasNoDefaultLib ;
1490
1490
1491
1491
const basePath = getDirectoryPath ( fileName ) ;
1492
+ const libraryBasePath = options . rootDir || options . configFilePath || getDirectoryPath ( file . fileName ) ;
1492
1493
if ( ! options . noResolve ) {
1493
1494
processReferencedFiles ( file , basePath ) ;
1494
- }
1495
-
1496
- const libraryRoot = computeCommonSourceDirectory ( files ) ;
1497
1495
1498
- processReferencedLibraries ( file , libraryRoot ) ;
1496
+ processReferencedLibraries ( file , libraryBasePath ) ;
1497
+ }
1499
1498
1500
1499
// always process imported modules to record module name resolutions
1501
1500
processImportedModules ( file , basePath ) ;
@@ -1521,12 +1520,34 @@ namespace ts {
1521
1520
function processReferencedLibraries ( file : SourceFile , compilationRoot : string ) {
1522
1521
const searchPaths = getEffectiveLibrarySearchPaths ( ) ;
1523
1522
for ( const ref of file . referencedLibraries ) {
1523
+ let foundIt = false ;
1524
+
1524
1525
for ( const path of searchPaths ) {
1525
- const combinedPath = combinePaths ( path , ref . fileName ) ;
1526
+ let typingFilename = "index.d.ts" ;
1527
+ const searchPath = combinePaths ( combinePaths ( compilationRoot , path ) , ref . fileName ) ;
1528
+ const packageJsonPath = combinePaths ( searchPath , "package.json" ) ;
1529
+ console . log ( 'Check for ' + packageJsonPath ) ;
1530
+ if ( host . fileExists ( packageJsonPath ) ) {
1531
+ let package : { typings ?: string } = { } ;
1532
+ try {
1533
+ package = JSON . parse ( host . readFile ( packageJsonPath ) ) ;
1534
+ } catch ( e ) { }
1535
+
1536
+ if ( package . typings ) {
1537
+ typingFilename = package . typings ;
1538
+ }
1539
+ }
1540
+
1541
+ const combinedPath = normalizePath ( combinePaths ( compilationRoot , combinePaths ( combinePaths ( path , ref . fileName ) , typingFilename ) ) ) ;
1526
1542
if ( host . fileExists ( combinedPath ) ) {
1527
- processSourceFile ( combinedPath , false , file , ref . pos , ref . end ) ;
1543
+ processSourceFile ( combinedPath , /*isDefaultLib*/ false , /*isReference*/ true , file , ref . pos , ref . end ) ;
1544
+ foundIt = true ;
1545
+ break ;
1528
1546
}
1529
1547
}
1548
+ if ( ! foundIt ) {
1549
+ fileProcessingDiagnostics . add ( createFileDiagnostic ( file , ref . pos , ref . end - ref . pos , Diagnostics . Cannot_find_name_0 , ref . fileName ) ) ;
1550
+ }
1530
1551
}
1531
1552
}
1532
1553
0 commit comments