Skip to content

Commit d5d5e11

Browse files
committed
fix(deps): properties with long arrow function declared
fix #706
1 parent 3047e54 commit d5d5e11

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/app/compiler/angular/deps/helpers/class-helper.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,10 @@ export class ClassHelper {
920920
};
921921
let jsdoctags;
922922

923+
if (property.initializer && property.initializer.kind === SyntaxKind.ArrowFunction) {
924+
result.defaultValue = '() => {...}';
925+
}
926+
923927
if (typeof result.name === 'undefined' && typeof property.name.expression !== 'undefined') {
924928
result.name = property.name.expression.text;
925929
}

test/src/cli/cli-generation-big-app.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,4 +759,9 @@ describe('CLI simple generation - big app', () => {
759759
'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string'
760760
);
761761
});
762+
763+
it('shorten long arrow function declaration for properties', () => {
764+
let file = read(distFolder + '/classes/Todo.html');
765+
expect(file).to.contain('() &#x3D;&gt; {...}</code>');
766+
});
762767
});

test/src/todomvc-ng2/src/app/shared/models/todo.model.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,20 @@ export class Todo extends Tada {
8484
return 5;
8585
}
8686

87-
abstract abstractMethod(input : string) : string;
87+
abstract abstractMethod(input: string): string;
8888

8989
async asyncMethod() {}
90+
91+
url2state = async <T>(defaults: Partial<T>) =>
92+
await this.route.queryParamMap
93+
.pipe(
94+
/** use first to make sure this only runs at component init time */
95+
first(),
96+
map(r => {}),
97+
catchError(e => {})
98+
)
99+
/** cast observable to promise */
100+
.toPromise();
90101
}
91102

92103
export type PopupPosition = ElementRef | HTMLElement;

0 commit comments

Comments
 (0)