@@ -17,6 +17,30 @@ namespace ts.projectSystem {
17
17
} )
18
18
} ;
19
19
20
+ const typeMapList = {
21
+ path : < Path > "/typeMapList.json" ,
22
+ content : JSON . stringify ( {
23
+ "jquery" : {
24
+ // jquery files can have names like "jquery-1.10.2.min.js" (or "jquery.intellisense.js")
25
+ "match" : "/jquery(-(\\.\\d+)+)?(\\.intellisense)?(\\.min)?\\.js$" ,
26
+ "types" : [ "jquery" ]
27
+ } ,
28
+ "WinJS" : {
29
+ "match" : "^(.*/winjs)/base\\.js$" , // If the winjs/base.js file is found..
30
+ "exclude" : [ [ "^" , 1 , "/.*" ] ] , // ..then exclude all files under the winjs folder
31
+ "types" : [ "winjs" ] // And fetch the @types package for WinJS
32
+ } ,
33
+ "Office Nuget" : {
34
+ "match" : "^(.*/1/office)/excel\\.debug\\.js$" , // Office NuGet package is installed under a "1/office" folder
35
+ "exclude" : [ [ "^" , 1 , "/.*" ] ] , // Exclude that whole folder if the file indicated above is found in it
36
+ "types" : [ "office" ] // @types package to fetch instead
37
+ } ,
38
+ "Minified files" : {
39
+ "match" : "^.*\\.min\\.js$" // Catch-all for minified files. Default exclude is the matched file.
40
+ }
41
+ } )
42
+ } ;
43
+
20
44
export interface PostExecAction {
21
45
readonly success : boolean ;
22
46
readonly callback : TI . RequestCompletedAction ;
@@ -1445,6 +1469,25 @@ namespace ts.projectSystem {
1445
1469
checkProjectActualFiles ( projectService . inferredProjects [ 1 ] , [ file3 . path ] ) ;
1446
1470
} ) ;
1447
1471
1472
+ it ( "ignores files excluded by the safe type list" , ( ) => {
1473
+ const file1 = {
1474
+ path : "/a/b/f1.ts" ,
1475
+ content : "export let x = 5"
1476
+ } ;
1477
+ const office = {
1478
+ path : "lib/1/office/excel.debug.js" ,
1479
+ content : "whoa do @@ not parse me ok thanks!!!"
1480
+ } ;
1481
+ const host = createServerHost ( [ typeMapList , file1 , office ] ) ;
1482
+ const projectService = createProjectService ( host ) ;
1483
+ projectService . loadSafeList ( typeMapList . path ) ;
1484
+
1485
+ projectService . openExternalProject ( { projectFileName : "project" , options : { } , rootFiles : toExternalFiles ( [ file1 . path , office . path ] ) } ) ;
1486
+ const proj = projectService . externalProjects [ 0 ] ;
1487
+ assert . deepEqual ( proj . getFileNames ( true ) , [ file1 . path ] ) ;
1488
+ assert . deepEqual ( proj . getTypeAcquisition ( ) . include , [ "office" ] ) ;
1489
+ } ) ;
1490
+
1448
1491
it ( "open file become a part of configured project if it is referenced from root file" , ( ) => {
1449
1492
const file1 = {
1450
1493
path : "/a/b/f1.ts" ,
@@ -1695,7 +1738,7 @@ namespace ts.projectSystem {
1695
1738
checkProjectActualFiles ( projectService . inferredProjects [ 1 ] , [ file2 . path ] ) ;
1696
1739
} ) ;
1697
1740
1698
- it ( "loading files with correct priority" , ( ) => {
1741
+ it ( "loading files with correct priority" , ( ) => {
1699
1742
const f1 = {
1700
1743
path : "/a/main.ts" ,
1701
1744
content : "let x = 1"
@@ -1720,14 +1763,14 @@ namespace ts.projectSystem {
1720
1763
} ) ;
1721
1764
projectService . openClientFile ( f1 . path ) ;
1722
1765
projectService . checkNumberOfProjects ( { configuredProjects : 1 } ) ;
1723
- checkProjectActualFiles ( projectService . configuredProjects [ 0 ] , [ f1 . path ] ) ;
1766
+ checkProjectActualFiles ( projectService . configuredProjects [ 0 ] , [ f1 . path ] ) ;
1724
1767
1725
1768
projectService . closeClientFile ( f1 . path ) ;
1726
1769
1727
1770
projectService . openClientFile ( f2 . path ) ;
1728
1771
projectService . checkNumberOfProjects ( { configuredProjects : 1 , inferredProjects : 1 } ) ;
1729
- checkProjectActualFiles ( projectService . configuredProjects [ 0 ] , [ f1 . path ] ) ;
1730
- checkProjectActualFiles ( projectService . inferredProjects [ 0 ] , [ f2 . path ] ) ;
1772
+ checkProjectActualFiles ( projectService . configuredProjects [ 0 ] , [ f1 . path ] ) ;
1773
+ checkProjectActualFiles ( projectService . inferredProjects [ 0 ] , [ f2 . path ] ) ;
1731
1774
} ) ;
1732
1775
1733
1776
it ( "tsconfig script block support" , ( ) => {
@@ -1845,7 +1888,7 @@ namespace ts.projectSystem {
1845
1888
// #3. Ensure no errors when compiler options aren't specified
1846
1889
const config3 = {
1847
1890
path : "/a/b/tsconfig.json" ,
1848
- content : JSON . stringify ( { } )
1891
+ content : JSON . stringify ( { } )
1849
1892
} ;
1850
1893
1851
1894
host = createServerHost ( [ file1 , file2 , config3 , libFile ] , { executingFilePath : combinePaths ( getDirectoryPath ( libFile . path ) , "tsc.js" ) } ) ;
@@ -3381,13 +3424,13 @@ namespace ts.projectSystem {
3381
3424
assert . equal ( ( < protocol . CompileOnSaveAffectedFileListSingleProject [ ] > response ) [ 0 ] . projectUsesOutFile , expectedUsesOutFile , "usesOutFile" ) ;
3382
3425
}
3383
3426
3384
- it ( "projectUsesOutFile should not be returned if not set" , ( ) => {
3427
+ it ( "projectUsesOutFile should not be returned if not set" , ( ) => {
3385
3428
test ( { } , /*expectedUsesOutFile*/ false ) ;
3386
3429
} ) ;
3387
- it ( "projectUsesOutFile should be true if outFile is set" , ( ) => {
3430
+ it ( "projectUsesOutFile should be true if outFile is set" , ( ) => {
3388
3431
test ( { outFile : "/a/out.js" } , /*expectedUsesOutFile*/ true ) ;
3389
3432
} ) ;
3390
- it ( "projectUsesOutFile should be true if out is set" , ( ) => {
3433
+ it ( "projectUsesOutFile should be true if out is set" , ( ) => {
3391
3434
test ( { out : "/a/out.js" } , /*expectedUsesOutFile*/ true ) ;
3392
3435
} ) ;
3393
3436
} ) ;
@@ -3468,7 +3511,7 @@ namespace ts.projectSystem {
3468
3511
3469
3512
const cancellationToken = new TestServerCancellationToken ( ) ;
3470
3513
const host = createServerHost ( [ f1 , config ] ) ;
3471
- const session = createSession ( host , /*typingsInstaller*/ undefined , ( ) => { } , cancellationToken ) ;
3514
+ const session = createSession ( host , /*typingsInstaller*/ undefined , ( ) => { } , cancellationToken ) ;
3472
3515
{
3473
3516
session . executeCommandSeq ( < protocol . OpenRequest > {
3474
3517
command : "open" ,
0 commit comments