@@ -56,7 +56,7 @@ export class AotPlugin implements Tapable {
56
56
private _tsConfigPath : string ;
57
57
private _entryModule : string ;
58
58
59
- private _donePromise : Promise < void > ;
59
+ private _donePromise : Promise < void > | null ;
60
60
private _compiler : any = null ;
61
61
private _compilation : any = null ;
62
62
@@ -66,10 +66,10 @@ export class AotPlugin implements Tapable {
66
66
private _basePath : string ;
67
67
private _genDir : string ;
68
68
69
- private _i18nFile : string ;
70
- private _i18nFormat : string ;
71
- private _locale : string ;
72
- private _missingTranslation : string ;
69
+ private _i18nFile ? : string ;
70
+ private _i18nFormat ? : string ;
71
+ private _locale ? : string ;
72
+ private _missingTranslation ? : string ;
73
73
74
74
private _diagnoseFiles : { [ path : string ] : boolean } = { } ;
75
75
private _firstRun = true ;
@@ -128,7 +128,7 @@ export class AotPlugin implements Tapable {
128
128
const message = ts . flattenDiagnosticMessageText ( diagnostic . messageText , '\n' ) ;
129
129
130
130
if ( diagnostic . file ) {
131
- const { line, character} = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ) ;
131
+ const { line, character} = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ! ) ;
132
132
throw new Error ( `${ diagnostic . file . fileName } (${ line + 1 } ,${ character + 1 } ): ${ message } )` ) ;
133
133
} else {
134
134
throw new Error ( message ) ;
@@ -166,7 +166,7 @@ export class AotPlugin implements Tapable {
166
166
}
167
167
168
168
const tsConfig = ts . parseJsonConfigFileContent (
169
- tsConfigJson , ts . sys , basePath , null , this . _tsConfigPath ) ;
169
+ tsConfigJson , ts . sys , basePath , undefined , this . _tsConfigPath ) ;
170
170
171
171
let fileNames = tsConfig . fileNames ;
172
172
this . _rootFilePath = fileNames ;
@@ -192,23 +192,23 @@ export class AotPlugin implements Tapable {
192
192
this . _basePath = basePath ;
193
193
this . _genDir = genDir ;
194
194
195
- if ( options . hasOwnProperty ( ' typeChecking' ) ) {
195
+ if ( options . typeChecking !== undefined ) {
196
196
this . _typeCheck = options . typeChecking ;
197
197
}
198
- if ( options . hasOwnProperty ( ' skipCodeGeneration' ) ) {
198
+ if ( options . skipCodeGeneration !== undefined ) {
199
199
this . _skipCodeGeneration = options . skipCodeGeneration ;
200
200
}
201
201
202
202
this . _compilerHost = new WebpackCompilerHost ( this . _compilerOptions , this . _basePath ) ;
203
203
204
204
// Override some files in the FileSystem.
205
- if ( options . hasOwnProperty ( ' hostOverrideFileSystem' ) ) {
205
+ if ( options . hostOverrideFileSystem ) {
206
206
for ( const filePath of Object . keys ( options . hostOverrideFileSystem ) ) {
207
207
this . _compilerHost . writeFile ( filePath , options . hostOverrideFileSystem [ filePath ] , false ) ;
208
208
}
209
209
}
210
210
// Override some files in the FileSystem with paths from the actual file system.
211
- if ( options . hasOwnProperty ( ' hostReplacementPaths' ) ) {
211
+ if ( options . hostReplacementPaths ) {
212
212
for ( const filePath of Object . keys ( options . hostReplacementPaths ) ) {
213
213
const replacementFilePath = options . hostReplacementPaths [ filePath ] ;
214
214
const content = this . _compilerHost . readFile ( replacementFilePath ) ;
@@ -345,7 +345,7 @@ export class AotPlugin implements Tapable {
345
345
return callback ( null , result ) ;
346
346
}
347
347
348
- this . done . then ( ( ) => {
348
+ this . done ! . then ( ( ) => {
349
349
result . resource = this . genDir ;
350
350
result . dependencies . forEach ( ( d : any ) => d . critical = false ) ;
351
351
result . resolveDependencies = ( _fs : any , _resource : any , _recursive : any ,
@@ -380,7 +380,7 @@ export class AotPlugin implements Tapable {
380
380
// Virtual file system.
381
381
compiler . resolvers . normal . plugin ( 'before-resolve' , ( request : any , cb : ( ) => void ) => {
382
382
if ( request . request . match ( / \. t s $ / ) ) {
383
- this . done . then ( ( ) => cb ( ) , ( ) => cb ( ) ) ;
383
+ this . done ! . then ( ( ) => cb ( ) , ( ) => cb ( ) ) ;
384
384
} else {
385
385
cb ( ) ;
386
386
}
@@ -432,21 +432,20 @@ export class AotPlugin implements Tapable {
432
432
return ;
433
433
}
434
434
435
- const diagnostics : ts . Diagnostic [ ] = [ ]
436
- . concat (
437
- this . _program . getCompilerOptions ( ) . declaration
438
- ? this . _program . getDeclarationDiagnostics ( sourceFile ) : [ ] ,
439
- this . _program . getSyntacticDiagnostics ( sourceFile ) ,
440
- this . _program . getSemanticDiagnostics ( sourceFile )
441
- ) ;
435
+ const diagnostics : Array < ts . Diagnostic > = [
436
+ ...( this . _program . getCompilerOptions ( ) . declaration
437
+ ? this . _program . getDeclarationDiagnostics ( sourceFile ) : [ ] ) ,
438
+ ...this . _program . getSyntacticDiagnostics ( sourceFile ) ,
439
+ ...this . _program . getSemanticDiagnostics ( sourceFile )
440
+ ] ;
442
441
443
442
if ( diagnostics . length > 0 ) {
444
443
diagnostics . forEach ( diagnostic => {
445
444
const messageText = ts . flattenDiagnosticMessageText ( diagnostic . messageText , '\n' ) ;
446
445
let message ;
447
446
448
447
if ( diagnostic . file ) {
449
- const position = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ) ;
448
+ const position = diagnostic . file . getLineAndCharacterOfPosition ( diagnostic . start ! ) ;
450
449
451
450
const sourceText = diagnostic . file . getFullText ( ) ;
452
451
let { line, character, fileName} = this . _translateSourceMap ( sourceText ,
@@ -532,7 +531,7 @@ export class AotPlugin implements Tapable {
532
531
533
532
if ( diagnostic . file ) {
534
533
const { line, character} = diagnostic . file . getLineAndCharacterOfPosition (
535
- diagnostic . start ) ;
534
+ diagnostic . start ! ) ;
536
535
return `${ diagnostic . file . fileName } (${ line + 1 } ,${ character + 1 } ): ${ message } )` ;
537
536
} else {
538
537
return message ;
0 commit comments