6
6
* found in the LICENSE file at https://angular.io/license
7
7
*/
8
8
9
- import { CompileDirectiveMetadata , CompileIdentifierMetadata , CompileNgModuleMetadata , CompileProviderMetadata , componentFactoryName , createHostComponentMeta , flatten , identifierName , sourceUrl , templateSourceUrl } from '../compile_metadata' ;
9
+ import { CompileDirectiveMetadata , CompileIdentifierMetadata , CompileNgModuleMetadata , CompileProviderMetadata , CompileTypeSummary , componentFactoryName , createHostComponentMeta , flatten , identifierName , sourceUrl , templateSourceUrl } from '../compile_metadata' ;
10
10
import { CompilerConfig } from '../config' ;
11
11
import { Identifiers , createIdentifier , createIdentifierToken } from '../identifiers' ;
12
12
import { CompileMetadataResolver } from '../metadata_resolver' ;
@@ -32,8 +32,8 @@ export class AotCompiler {
32
32
private _metadataResolver : CompileMetadataResolver , private _templateParser : TemplateParser ,
33
33
private _styleCompiler : StyleCompiler , private _viewCompiler : ViewCompiler ,
34
34
private _ngModuleCompiler : NgModuleCompiler , private _outputEmitter : OutputEmitter ,
35
- private _summaryResolver : SummaryResolver < StaticSymbol > , private _localeId : string ,
36
- private _translationFormat : string , private _genFilePreamble : string ,
35
+ private _summaryResolver : SummaryResolver < StaticSymbol > , private _localeId : string | null ,
36
+ private _translationFormat : string | null , private _genFilePreamble : string | null ,
37
37
private _symbolResolver : StaticSymbolResolver ) { }
38
38
39
39
clearCache ( ) { this . _metadataResolver . clearCache ( ) ; }
@@ -113,11 +113,11 @@ export class AotCompiler {
113
113
targetExportedVars : string [ ] ) : GeneratedFile {
114
114
const symbolSummaries = this . _symbolResolver . getSymbolsOf ( srcFileUrl )
115
115
. map ( symbol => this . _symbolResolver . resolveSymbol ( symbol ) ) ;
116
- const typeSummaries = [
117
- ...ngModules . map ( ref => this . _metadataResolver . getNgModuleSummary ( ref ) ) ,
118
- ...directives . map ( ref => this . _metadataResolver . getDirectiveSummary ( ref ) ) ,
119
- ...pipes . map ( ref => this . _metadataResolver . getPipeSummary ( ref ) ) ,
120
- ...injectables . map ( ref => this . _metadataResolver . getInjectableSummary ( ref ) )
116
+ const typeSummaries : CompileTypeSummary [ ] = [
117
+ ...ngModules . map ( ref => this . _metadataResolver . getNgModuleSummary ( ref ) ! ) ,
118
+ ...directives . map ( ref => this . _metadataResolver . getDirectiveSummary ( ref ) ! ) ,
119
+ ...pipes . map ( ref => this . _metadataResolver . getPipeSummary ( ref ) ! ) ,
120
+ ...injectables . map ( ref => this . _metadataResolver . getInjectableSummary ( ref ) ! )
121
121
] ;
122
122
const { json, exportAs} = serializeSummaries (
123
123
this . _summaryResolver , this . _symbolResolver , symbolSummaries , typeSummaries ) ;
@@ -130,7 +130,7 @@ export class AotCompiler {
130
130
}
131
131
132
132
private _compileModule ( ngModuleType : StaticSymbol , targetStatements : o . Statement [ ] ) : string {
133
- const ngModule = this . _metadataResolver . getNgModuleMetadata ( ngModuleType ) ;
133
+ const ngModule = this . _metadataResolver . getNgModuleMetadata ( ngModuleType ) ! ;
134
134
const providers : CompileProviderMetadata [ ] = [ ] ;
135
135
136
136
if ( this . _localeId ) {
@@ -183,19 +183,19 @@ export class AotCompiler {
183
183
o . variable ( hostViewFactoryVar ) , new o . LiteralMapExpr ( inputsExprs ) ,
184
184
new o . LiteralMapExpr ( outputsExprs ) ,
185
185
o . literalArr (
186
- compMeta . template . ngContentSelectors . map ( selector => o . literal ( selector ) ) )
186
+ compMeta . template ! . ngContentSelectors . map ( selector => o . literal ( selector ) ) )
187
187
] ) )
188
188
. toDeclStmt (
189
189
o . importType (
190
- createIdentifier ( Identifiers . ComponentFactory ) , [ o . importType ( compMeta . type ) ] ,
190
+ createIdentifier ( Identifiers . ComponentFactory ) , [ o . importType ( compMeta . type ) ! ] ,
191
191
[ o . TypeModifier . Const ] ) ,
192
192
[ o . StmtModifier . Final ] ) ) ;
193
193
return compFactoryVar ;
194
194
}
195
195
196
196
private _compileComponent (
197
197
compMeta : CompileDirectiveMetadata , ngModule : CompileNgModuleMetadata ,
198
- directiveIdentifiers : CompileIdentifierMetadata [ ] , componentStyles : CompiledStylesheet ,
198
+ directiveIdentifiers : CompileIdentifierMetadata [ ] , componentStyles : CompiledStylesheet | null ,
199
199
fileSuffix : string ,
200
200
targetStatements : o . Statement [ ] ) : { viewClassVar : string , compRenderTypeVar : string } {
201
201
const directives =
@@ -204,8 +204,8 @@ export class AotCompiler {
204
204
pipe => this . _metadataResolver . getPipeSummary ( pipe . reference ) ) ;
205
205
206
206
const { template : parsedTemplate , pipes : usedPipes } = this . _templateParser . parse (
207
- compMeta , compMeta . template . template , directives , pipes , ngModule . schemas ,
208
- templateSourceUrl ( ngModule . type , compMeta , compMeta . template ) ) ;
207
+ compMeta , compMeta . template ! . template ! , directives , pipes , ngModule . schemas ,
208
+ templateSourceUrl ( ngModule . type , compMeta , compMeta . template ! ) ) ;
209
209
const stylesExpr = componentStyles ? o . variable ( componentStyles . stylesVar ) : o . literalArr ( [ ] ) ;
210
210
const viewResult =
211
211
this . _viewCompiler . compileComponent ( compMeta , parsedTemplate , stylesExpr , usedPipes ) ;
@@ -221,8 +221,9 @@ export class AotCompiler {
221
221
fileUrl : string , stylesCompileResult : CompiledStylesheet , fileSuffix : string ) : GeneratedFile {
222
222
_resolveStyleStatements ( this . _symbolResolver , stylesCompileResult , fileSuffix ) ;
223
223
return this . _codegenSourceModule (
224
- fileUrl , _stylesModuleUrl (
225
- stylesCompileResult . meta . moduleUrl , stylesCompileResult . isShimmed , fileSuffix ) ,
224
+ fileUrl ,
225
+ _stylesModuleUrl (
226
+ stylesCompileResult . meta . moduleUrl ! , stylesCompileResult . isShimmed , fileSuffix ) ,
226
227
stylesCompileResult . statements , [ stylesCompileResult . stylesVar ] ) ;
227
228
}
228
229
0 commit comments