From c356caa0d5d412ee1ef91d171559af2d89f39a6c Mon Sep 17 00:00:00 2001 From: Giulio Caprino Date: Thu, 17 Jun 2021 17:52:30 +0100 Subject: [PATCH] fix(transformer): ignore namespace when resolving a declaration (#793) --- src/transformer/descriptor/helper/helper.ts | 3 ++- .../declarations/declarations.test.ts | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/transformer/descriptor/helper/helper.ts b/src/transformer/descriptor/helper/helper.ts index 68e77177d..a1f897a05 100644 --- a/src/transformer/descriptor/helper/helper.ts +++ b/src/transformer/descriptor/helper/helper.ts @@ -155,7 +155,8 @@ export namespace TypescriptHelper { declarations.find( (declaration: ts.Declaration) => !ts.isVariableDeclaration(declaration) && - !ts.isFunctionDeclaration(declaration) + !ts.isFunctionDeclaration(declaration) && + !ts.isModuleDeclaration(declaration) ) || declarations[0] ); } diff --git a/test/transformer/descriptor/declarations/declarations.test.ts b/test/transformer/descriptor/declarations/declarations.test.ts index 947b8cee5..042d8587d 100644 --- a/test/transformer/descriptor/declarations/declarations.test.ts +++ b/test/transformer/descriptor/declarations/declarations.test.ts @@ -127,6 +127,23 @@ describe('declarations', () => { }); }); + describe('interface and namespace', () => { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + namespace InterfaceNamespaceTest {} + + interface InterfaceNamespaceTest { + value: boolean; + value2: string; + } + + it('should ignore the namespace', () => { + const properties: InterfaceNamespaceTest = createMock(); + expect(properties.value).toBe(false); + expect(properties.value2).toBe(''); + }); + }); + describe('type', () => { // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore