Skip to content

Commit c8d00dc

Browse files
committed
fix(codegen): add explicit any to class fields
fixes angular#8204 Closes angular#8205
1 parent 0b6865d commit c8d00dc

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

modules/angular2/src/compiler/output/ts_emitter.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ class _TsEmitterVisitor extends AbstractEmitterVisitor implements o.TypeVisitor
130130
if (isPresent(field.type)) {
131131
ctx.print(`:`);
132132
field.type.visitType(this, ctx);
133+
} else {
134+
ctx.print(`: any`);
133135
}
134136
ctx.println(`;`);
135137
}

modules/angular2/test/compiler/output/ts_emitter_spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ export function main() {
235235
it('should support declaring fields', () => {
236236
expect(emitStmt(new o.ClassStmt('SomeClass', null, [new o.ClassField('someField')], [],
237237
null, [])))
238-
.toEqual(['class SomeClass {', ' someField;', '}'].join('\n'));
238+
.toEqual(['class SomeClass {', ' someField: any;', '}'].join('\n'));
239239
expect(emitStmt(new o.ClassStmt('SomeClass', null,
240240
[new o.ClassField('someField', o.INT_TYPE)], [], null, [])))
241241
.toEqual(['class SomeClass {', ' someField:number;', '}'].join('\n'));

0 commit comments

Comments
 (0)