diff --git a/packages/compiler-cli/integrationtest/test/i18n_spec.ts b/packages/compiler-cli/integrationtest/test/i18n_spec.ts index 549b5744ff..0872e96660 100644 --- a/packages/compiler-cli/integrationtest/test/i18n_spec.ts +++ b/packages/compiler-cli/integrationtest/test/i18n_spec.ts @@ -34,10 +34,10 @@ const EXPECTED_XMB = ` ]> - src/basic.ts:1translate me - src/basic.ts:5src/entry_components.ts:1Welcome node_modules/third_party/other_comp.d.ts:1,2other-3rdP-component multi-lines + src/basic.ts:1translate me + src/basic.ts:5src/entry_components.ts:1Welcome `; @@ -45,6 +45,14 @@ const EXPECTED_XLIFF = ` + + other-3rdP-component +multi-lines + + node_modules/third_party/other_comp.d.ts + 1 + + translate me @@ -65,14 +73,6 @@ const EXPECTED_XLIFF = ` 1 - - other-3rdP-component -multi-lines - - node_modules/third_party/other_comp.d.ts - 1 - - @@ -81,6 +81,15 @@ multi-lines const EXPECTED_XLIFF2 = ` + + + node_modules/third_party/other_comp.d.ts:1,2 + + + other-3rdP-component +multi-lines + + desc @@ -100,15 +109,6 @@ const EXPECTED_XLIFF2 = ` Welcome - - - node_modules/third_party/other_comp.d.ts:1,2 - - - other-3rdP-component -multi-lines - - `; diff --git a/packages/compiler-cli/test/diagnostics/check_types_spec.ts b/packages/compiler-cli/test/diagnostics/check_types_spec.ts index 8069f5add2..9a3dc9439e 100644 --- a/packages/compiler-cli/test/diagnostics/check_types_spec.ts +++ b/packages/compiler-cli/test/diagnostics/check_types_spec.ts @@ -114,6 +114,11 @@ describe('ng type checker', () => { () => { a('{{maybePerson!.name}}'); }); it('should accept a safe property access of a nullable person', () => { a('{{maybePerson?.name}}'); }); + + it('should accept using a library pipe', () => { a('{{1 | libPipe}}'); }); + it('should accept using a library directive', + () => { a('
{{libDir.name}}
'); }); + it('should accept a function call', () => { a('{{getName()}}'); }); it('should reject an invalid method', () => { r('
{{getFame()}}
', @@ -211,13 +216,37 @@ function appComponentSource(): string { const QUICKSTART = { 'src/app.component.ts': appComponentSource(), 'src/app.component.html': '

Hello {{name}}

', + 'src/lib.ts': ` + import {Pipe, Directive} from '@angular/core'; + + @Pipe({ name: 'libPipe' }) + export class LibPipe { + transform(n: number): number { return n + 1; } + } + + @Directive({ + selector: '[libDir]', + exportAs: 'libDir' + }) + export class LibDirective { + name: string; + } + `, 'src/app.module.ts': ` import { NgModule } from '@angular/core'; import { AppComponent, APipe, ADirective } from './app.component'; + import { LibDirective, LibPipe } from './lib'; + + @NgModule({ + declarations: [ LibPipe, LibDirective ], + exports: [ LibPipe, LibDirective ], + }) + export class LibModule { } @NgModule({ declarations: [ AppComponent, APipe, ADirective ], - bootstrap: [ AppComponent ] + bootstrap: [ AppComponent ], + imports: [ LibModule ] }) export class AppModule { } ` diff --git a/packages/compiler/src/aot/compiler.ts b/packages/compiler/src/aot/compiler.ts index 317ba315f2..075547f56d 100644 --- a/packages/compiler/src/aot/compiler.ts +++ b/packages/compiler/src/aot/compiler.ts @@ -204,8 +204,8 @@ export class AotCompiler { // and they also cause TypeScript to include these files into the program too, // which will make them part of the analyzedFiles. const externalReferences: StaticSymbol[] = [ - ...ngModuleMeta.declaredDirectives.map(d => d.reference), - ...ngModuleMeta.declaredPipes.map(d => d.reference), + ...ngModuleMeta.transitiveModule.directives.map(d => d.reference), + ...ngModuleMeta.transitiveModule.pipes.map(d => d.reference), ...ngModuleMeta.importedModules.map(m => m.type.reference), ...ngModuleMeta.exportedModules.map(m => m.type.reference), ];