diff --git a/packages/compiler-cli/src/ngtsc/reflection/src/typescript.ts b/packages/compiler-cli/src/ngtsc/reflection/src/typescript.ts index a08a088a68ccb..7c3ebc6e56046 100644 --- a/packages/compiler-cli/src/ngtsc/reflection/src/typescript.ts +++ b/packages/compiler-cli/src/ngtsc/reflection/src/typescript.ts @@ -548,6 +548,8 @@ export function reflectTypeEntityToDeclaration( throw new Error(`Module specifier is not a string`); } return {node, from: importDecl.moduleSpecifier.text}; + } else if (ts.isModuleDeclaration(decl)) { + return {node, from: null}; } else { throw new Error(`Unknown import type?`); } diff --git a/packages/compiler-cli/src/ngtsc/reflection/test/ts_host_spec.ts b/packages/compiler-cli/src/ngtsc/reflection/test/ts_host_spec.ts index d298d2441cd3a..fd5c7c7ffb135 100644 --- a/packages/compiler-cli/src/ngtsc/reflection/test/ts_host_spec.ts +++ b/packages/compiler-cli/src/ngtsc/reflection/test/ts_host_spec.ts @@ -153,6 +153,30 @@ runInEachFileSystem(() => { expectParameter(args[0], 'bar', {moduleName: './bar', name: 'Bar'}); }); + it('should reflect an argument from a namespace declarations', () => { + const {program} = makeProgram([{ + name: _('/entry.ts'), + contents: ` + export declare class Bar {} + declare namespace i1 { + export { + Bar, + } + } + + class Foo { + constructor(bar: i1.Bar) {} + } + ` + }]); + const clazz = getDeclaration(program, _('/entry.ts'), 'Foo', isNamedClassDeclaration); + const checker = program.getTypeChecker(); + const host = new TypeScriptReflectionHost(checker); + const args = host.getConstructorParameters(clazz)!; + expect(args.length).toBe(1); + expectParameter(args[0], 'bar', 'i1.Bar'); + }); + it('should reflect an argument from a default import', () => { const {program} = makeProgram([ {