Skip to content

Commit

Permalink
fix(transformer): ignore namespace when resolving a declaration (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pmyl authored Jun 17, 2021
1 parent 84c24f7 commit c356caa
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/transformer/descriptor/helper/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]
);
}
Expand Down
17 changes: 17 additions & 0 deletions test/transformer/descriptor/declarations/declarations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<InterfaceNamespaceTest>();
expect(properties.value).toBe(false);
expect(properties.value2).toBe('');
});
});

describe('type', () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down

0 comments on commit c356caa

Please sign in to comment.