Revert "fix(compiler): Generates function expressions as returning any (#9980)"
This reverts commit eb5763c23f
.
This commit is contained in:
parent
34feecf60e
commit
9229bbbc80
|
@ -6,8 +6,7 @@
|
|||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
import {NgFor} from '@angular/common';
|
||||
import {Component, Directive, QueryList, ViewChild, ViewChildren} from '@angular/core';
|
||||
import {Component, QueryList, ViewChild, ViewChildren} from '@angular/core';
|
||||
|
||||
@Component({selector: 'comp-for-child-query', template: 'child'})
|
||||
export class CompForChildQuery {
|
||||
|
@ -22,20 +21,3 @@ export class CompWithChildQuery {
|
|||
@ViewChild(CompForChildQuery) child: CompForChildQuery;
|
||||
@ViewChildren(CompForChildQuery) children: QueryList<CompForChildQuery>;
|
||||
}
|
||||
|
||||
@Directive({selector: '[directive-for-query]'})
|
||||
export class DirectiveForQuery {
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'comp-with-directive-child',
|
||||
directives: [DirectiveForQuery, NgFor],
|
||||
template: `<div>
|
||||
<div *ngFor="let data of divData" directive-for-query>{{data}}</div>
|
||||
</div>`
|
||||
})
|
||||
export class CompWithDirectiveChild {
|
||||
@ViewChildren(DirectiveForQuery) children: QueryList<DirectiveForQuery>;
|
||||
|
||||
divData: string[];
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor
|
|||
ctx.print(`(`);
|
||||
this._visitParams(ast.params, ctx);
|
||||
ctx.print(`):`);
|
||||
this.visitType(ast.type, ctx);
|
||||
this.visitType(ast.type, ctx, 'void');
|
||||
ctx.println(` => {`);
|
||||
ctx.incIndent();
|
||||
this.visitAllStatements(ast.statements, ctx);
|
||||
|
|
|
@ -143,11 +143,11 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should support function expressions', () => {
|
||||
expect(emitStmt(o.fn([], []).toStmt())).toEqual(['():any => {', '};'].join('\n'));
|
||||
expect(emitStmt(o.fn([], []).toStmt())).toEqual(['():void => {', '};'].join('\n'));
|
||||
expect(emitStmt(o.fn([], [new o.ReturnStatement(o.literal(1))], o.INT_TYPE).toStmt()))
|
||||
.toEqual(['():number => {', ' return 1;\n};'].join('\n'));
|
||||
expect(emitStmt(o.fn([new o.FnParam('param1', o.INT_TYPE)], []).toStmt())).toEqual([
|
||||
'(param1:number):any => {', '};'
|
||||
'(param1:number):void => {', '};'
|
||||
].join('\n'));
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue