Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Commit

Permalink
fix(core): error on overloaded functions
Browse files Browse the repository at this point in the history
fix #85
  • Loading branch information
urish committed Dec 3, 2018
1 parent 45a85e5 commit b5339a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions packages/typewiz-core/src/instrument.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ describe('instrument', () => {
);
});

it('should not instrument a function declaration that has no a body', () => {
// See issue #85 for details
const input = `function foo(n: number): void;`;
expect(instrument(input, 'test.ts')).toContain(astPrettyPrint('function foo(n: number): void;'));
});

describe('instrumentCallExpressions', () => {
it('should instrument function calls', () => {
const input = `foo(bar)`;
Expand Down
2 changes: 1 addition & 1 deletion packages/typewiz-core/src/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ function visitorFactory(
}

const isArrow = ts.isArrowFunction(node);
if (ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node) || ts.isArrowFunction(node)) {
if ((ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node) || ts.isArrowFunction(node)) && node.body) {
const instrumentStatements: ts.ExpressionStatement[] = [];
if (options.instrumentImplicitThis && needsThisInstrumentation(node, semanticDiagnostics)) {
const opts: IExtraOptions = { thisType: true };
Expand Down

0 comments on commit b5339a6

Please sign in to comment.