@@ -218,15 +218,14 @@ export class AotCompiler {
218
218
219
219
const externalReferenceVars = new Map < any , string > ( ) ;
220
220
externalReferences . forEach ( ( ref , typeIndex ) => {
221
- if ( this . _host . isSourceFile ( ref . filePath ) ) {
222
- externalReferenceVars . set ( ref , `_decl${ ngModuleIndex } _${ typeIndex } ` ) ;
223
- }
221
+ externalReferenceVars . set ( ref , `_decl${ ngModuleIndex } _${ typeIndex } ` ) ;
224
222
} ) ;
225
223
externalReferenceVars . forEach ( ( varName , reference ) => {
226
224
outputCtx . statements . push (
227
225
o . variable ( varName )
228
226
. set ( o . NULL_EXPR . cast ( o . DYNAMIC_TYPE ) )
229
- . toDeclStmt ( o . expressionType ( outputCtx . importExpr ( reference ) ) ) ) ;
227
+ . toDeclStmt ( o . expressionType ( outputCtx . importExpr (
228
+ reference , /* typeParams */ null , /* useSummaries */ false ) ) ) ) ;
230
229
} ) ;
231
230
232
231
if ( emitFlags & StubEmitFlags . TypeCheck ) {
@@ -515,35 +514,38 @@ export class AotCompiler {
515
514
}
516
515
517
516
private _createOutputContext ( genFilePath : string ) : OutputContext {
518
- const importExpr = ( symbol : StaticSymbol , typeParams : o . Type [ ] | null = null ) => {
519
- if ( ! ( symbol instanceof StaticSymbol ) ) {
520
- throw new Error ( `Internal error: unknown identifier ${ JSON . stringify ( symbol ) } ` ) ;
521
- }
522
- const arity = this . _symbolResolver . getTypeArity ( symbol ) || 0 ;
523
- const { filePath, name, members} = this . _symbolResolver . getImportAs ( symbol ) || symbol ;
524
- const importModule = this . _fileNameToModuleName ( filePath , genFilePath ) ;
525
-
526
- // It should be good enough to compare filePath to genFilePath and if they are equal
527
- // there is a self reference. However, ngfactory files generate to .ts but their
528
- // symbols have .d.ts so a simple compare is insufficient. They should be canonical
529
- // and is tracked by #17705.
530
- const selfReference = this . _fileNameToModuleName ( genFilePath , genFilePath ) ;
531
- const moduleName = importModule === selfReference ? null : importModule ;
532
-
533
- // If we are in a type expression that refers to a generic type then supply
534
- // the required type parameters. If there were not enough type parameters
535
- // supplied, supply any as the type. Outside a type expression the reference
536
- // should not supply type parameters and be treated as a simple value reference
537
- // to the constructor function itself.
538
- const suppliedTypeParams = typeParams || [ ] ;
539
- const missingTypeParamsCount = arity - suppliedTypeParams . length ;
540
- const allTypeParams =
541
- suppliedTypeParams . concat ( new Array ( missingTypeParamsCount ) . fill ( o . DYNAMIC_TYPE ) ) ;
542
- return members . reduce (
543
- ( expr , memberName ) => expr . prop ( memberName ) ,
544
- < o . Expression > o . importExpr (
545
- new o . ExternalReference ( moduleName , name , null ) , allTypeParams ) ) ;
546
- } ;
517
+ const importExpr =
518
+ ( symbol : StaticSymbol , typeParams : o . Type [ ] | null = null ,
519
+ useSummaries : boolean = true ) => {
520
+ if ( ! ( symbol instanceof StaticSymbol ) ) {
521
+ throw new Error ( `Internal error: unknown identifier ${ JSON . stringify ( symbol ) } ` ) ;
522
+ }
523
+ const arity = this . _symbolResolver . getTypeArity ( symbol ) || 0 ;
524
+ const { filePath, name, members} =
525
+ this . _symbolResolver . getImportAs ( symbol , useSummaries ) || symbol ;
526
+ const importModule = this . _fileNameToModuleName ( filePath , genFilePath ) ;
527
+
528
+ // It should be good enough to compare filePath to genFilePath and if they are equal
529
+ // there is a self reference. However, ngfactory files generate to .ts but their
530
+ // symbols have .d.ts so a simple compare is insufficient. They should be canonical
531
+ // and is tracked by #17705.
532
+ const selfReference = this . _fileNameToModuleName ( genFilePath , genFilePath ) ;
533
+ const moduleName = importModule === selfReference ? null : importModule ;
534
+
535
+ // If we are in a type expression that refers to a generic type then supply
536
+ // the required type parameters. If there were not enough type parameters
537
+ // supplied, supply any as the type. Outside a type expression the reference
538
+ // should not supply type parameters and be treated as a simple value reference
539
+ // to the constructor function itself.
540
+ const suppliedTypeParams = typeParams || [ ] ;
541
+ const missingTypeParamsCount = arity - suppliedTypeParams . length ;
542
+ const allTypeParams =
543
+ suppliedTypeParams . concat ( new Array ( missingTypeParamsCount ) . fill ( o . DYNAMIC_TYPE ) ) ;
544
+ return members . reduce (
545
+ ( expr , memberName ) => expr . prop ( memberName ) ,
546
+ < o . Expression > o . importExpr (
547
+ new o . ExternalReference ( moduleName , name , null ) , allTypeParams ) ) ;
548
+ } ;
547
549
548
550
return { statements : [ ] , genFilePath, importExpr} ;
549
551
}
0 commit comments