@@ -16,7 +16,7 @@ namespace ts.server {
1616 class TypingsCacheEntry {
1717 readonly typingOptions : TypingOptions ;
1818 readonly compilerOptions : CompilerOptions ;
19- readonly typings : string [ ] ;
19+ readonly typings : TypingsArray ;
2020 }
2121
2222 const emptyArray : any [ ] = [ ] ;
@@ -43,9 +43,7 @@ namespace ts.server {
4343 if ( ( arr1 || emptyArray ) . length === 0 && ( arr2 || emptyArray ) . length === 0 ) {
4444 return true ;
4545 }
46- /* tslint:disable:no-null-keyword */
47- const set : Map < boolean > = Object . create ( null ) ;
48- /* tslint:enable:no-null-keyword */
46+ const set : Map < boolean > = createMap < boolean > ( ) ;
4947 let unique = 0 ;
5048
5149 for ( const v of arr1 ) {
@@ -77,24 +75,33 @@ namespace ts.server {
7775 return opt1 . allowJs != opt2 . allowJs ;
7876 }
7977
78+ export interface TypingsArray extends ReadonlyArray < string > {
79+ " __typingsArrayBrand" : any ;
80+ }
81+
82+ function toTypingsArray ( arr : string [ ] ) : TypingsArray {
83+ arr . sort ( ) ;
84+ return < any > arr ;
85+ }
86+
8087 export class TypingsCache {
8188 private readonly perProjectCache : Map < TypingsCacheEntry > = createMap < TypingsCacheEntry > ( ) ;
8289
8390 constructor ( private readonly installer : ITypingsInstaller ) {
8491 }
8592
86- getTypingsForProject ( project : Project ) : Path [ ] {
93+ getTypingsForProject ( project : Project ) : TypingsArray {
8794 const typingOptions = getTypingOptionsForProjects ( project ) ;
8895
8996 if ( ! typingOptions . enableAutoDiscovery ) {
90- return emptyArray ;
97+ return < any > emptyArray ;
9198 }
9299
93100 const entry = this . perProjectCache [ project . getProjectName ( ) ] ;
94101 if ( ! entry || typingOptionsChanged ( typingOptions , entry . typingOptions ) || compilerOptionsChanged ( project . getCompilerOptions ( ) , entry . compilerOptions ) ) {
95102 this . installer . enqueueInstallTypingsRequest ( project , typingOptions ) ;
96103 }
97- return entry ? entry . typings : emptyArray ;
104+ return entry ? entry . typings : < any > emptyArray ;
98105 }
99106
100107 invalidateCachedTypingsForProject ( project : Project ) {
@@ -109,7 +116,7 @@ namespace ts.server {
109116 this . perProjectCache [ projectName ] = {
110117 compilerOptions,
111118 typingOptions,
112- typings : newTypings
119+ typings : toTypingsArray ( newTypings )
113120 } ;
114121 }
115122
0 commit comments