Skip to content

Commit

Permalink
fix(deps): properties with long arrow function declared
Browse files Browse the repository at this point in the history
fix #706
  • Loading branch information
vogloblinsky committed Jan 1, 2019
1 parent 3047e54 commit d5d5e11
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/app/compiler/angular/deps/helpers/class-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,10 @@ export class ClassHelper {
};
let jsdoctags;

if (property.initializer && property.initializer.kind === SyntaxKind.ArrowFunction) {
result.defaultValue = '() => {...}';
}

if (typeof result.name === 'undefined' && typeof property.name.expression !== 'undefined') {
result.name = property.name.expression.text;
}
Expand Down
5 changes: 5 additions & 0 deletions test/src/cli/cli-generation-big-app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,4 +759,9 @@ describe('CLI simple generation - big app', () => {
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'
);
});

it('shorten long arrow function declaration for properties', () => {
let file = read(distFolder + '/classes/Todo.html');
expect(file).to.contain('() &#x3D;&gt; {...}</code>');
});
});
13 changes: 12 additions & 1 deletion test/src/todomvc-ng2/src/app/shared/models/todo.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,20 @@ export class Todo extends Tada {
return 5;
}

abstract abstractMethod(input : string) : string;
abstract abstractMethod(input: string): string;

async asyncMethod() {}

url2state = async <T>(defaults: Partial<T>) =>
await this.route.queryParamMap
.pipe(
/** use first to make sure this only runs at component init time */
first(),
map(r => {}),
catchError(e => {})
)
/** cast observable to promise */
.toPromise();
}

export type PopupPosition = ElementRef | HTMLElement;

0 comments on commit d5d5e11

Please sign in to comment.