7
7
*/
8
8
9
9
import * as fs from 'fs' ;
10
+ import * as path from 'path' ;
10
11
import * as ts from 'typescript' ;
11
12
12
13
export interface Directory { [ name : string ] : ( Directory | string ) ; }
@@ -54,8 +55,10 @@ export class Host implements ts.LanguageServiceHost {
54
55
if ( this . overrides . has ( fileName ) ) {
55
56
return this . overrides . get ( fileName ) ;
56
57
}
57
- if ( fileName . endsWith ( 'lib.d.ts' ) ) {
58
- return fs . readFileSync ( ts . getDefaultLibFilePath ( this . getCompilationSettings ( ) ) , 'utf8' ) ;
58
+ if ( / l i b ( .* ) \. d \. t s / . test ( fileName ) ) {
59
+ const libDirPath = path . dirname ( ts . getDefaultLibFilePath ( this . getCompilationSettings ( ) ) ) ;
60
+ const libPath = path . join ( libDirPath , fileName ) ;
61
+ return fs . readFileSync ( libPath , 'utf8' ) ;
59
62
}
60
63
const current = open ( this . directory , fileName ) ;
61
64
if ( typeof current === 'string' ) return current ;
@@ -76,6 +79,9 @@ export function open(directory: Directory, fileName: string): Directory|string|u
76
79
}
77
80
78
81
export class MockNode implements ts . Node {
82
+ decorators ?: ts . NodeArray < ts . Decorator > ;
83
+ modifiers ?: ts . NodeArray < ts . Modifier > ;
84
+ parent ! : ts . Node ;
79
85
constructor (
80
86
public kind : ts . SyntaxKind = ts . SyntaxKind . Identifier , public flags : ts . NodeFlags = 0 ,
81
87
public pos : number = 0 , public end : number = 0 ) { }
@@ -101,6 +107,11 @@ export class MockNode implements ts.Node {
101
107
}
102
108
103
109
export class MockIdentifier extends MockNode implements ts . Identifier {
110
+ originalKeywordKind ?: ts . SyntaxKind ;
111
+ isInJSDocNamespace ?: boolean ;
112
+ decorators ?: ts . NodeArray < ts . Decorator > ;
113
+ modifiers ?: ts . NodeArray < ts . Modifier > ;
114
+ parent ! : ts . Node ;
104
115
public text : string ;
105
116
// TODO(issue/24571): remove '!'.
106
117
public escapedText ! : ts . __String ;
@@ -124,6 +135,12 @@ export class MockIdentifier extends MockNode implements ts.Identifier {
124
135
}
125
136
126
137
export class MockVariableDeclaration extends MockNode implements ts . VariableDeclaration {
138
+ parent ! : ts . VariableDeclarationList | ts . CatchClause ;
139
+ exclamationToken ?: ts . Token < ts . SyntaxKind . ExclamationToken > ;
140
+ type ?: ts . TypeNode ;
141
+ initializer ?: ts . Expression ;
142
+ decorators ?: ts . NodeArray < ts . Decorator > ;
143
+ modifiers ?: ts . NodeArray < ts . Modifier > ;
127
144
// tslint:disable-next-line
128
145
public _declarationBrand : any ;
129
146
@@ -140,6 +157,11 @@ export class MockVariableDeclaration extends MockNode implements ts.VariableDecl
140
157
}
141
158
142
159
export class MockSymbol implements ts . Symbol {
160
+ declarations ! : ts . Declaration [ ] ;
161
+ valueDeclaration ! : ts . Declaration ;
162
+ members ?: ts . UnderscoreEscapedMap < ts . Symbol > ;
163
+ exports ?: ts . UnderscoreEscapedMap < ts . Symbol > ;
164
+ globalExports ?: ts . UnderscoreEscapedMap < ts . Symbol > ;
143
165
// TODO(issue/24571): remove '!'.
144
166
public escapedName ! : ts . __String ;
145
167
constructor (
0 commit comments