Skip to content

Commit f864aa1

Browse files
committed
fix(class fields): handle untyped fields
1 parent d6193e9 commit f864aa1

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

tools/transpiler/spec/types_spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ class Foo {
5151
class WithFields {
5252
name: string;
5353
static id: number;
54+
untyped;
55+
static staticUntyped;
5456
}
5557

5658

tools/transpiler/src/outputgeneration/DartParseTreeWriter.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import {
1515
OPEN_SQUARE,
1616
SEMI_COLON,
1717
STAR,
18-
STATIC
18+
STATIC,
19+
VAR
1920
} from 'traceur/src/syntax/TokenType';
2021

2122
import {
@@ -43,8 +44,13 @@ export class DartParseTreeWriter extends JavaScriptParseTreeWriter {
4344
this.writeSpace_();
4445
}
4546

46-
this.writeType_(tree.typeAnnotation);
47+
if (tree.typeAnnotation === null) {
48+
this.write_(VAR);
49+
} else {
50+
this.writeType_(tree.typeAnnotation);
51+
}
4752
this.writeSpace_();
53+
4854
this.visitAny(tree.name);
4955
this.write_(SEMI_COLON);
5056
}
@@ -249,7 +255,7 @@ export class DartParseTreeWriter extends JavaScriptParseTreeWriter {
249255
if (tree.typeAnnotation) {
250256
this.writeType_(tree.typeAnnotation);
251257
} else {
252-
this.write_('var');
258+
this.write_(VAR);
253259
this.writeSpace_();
254260
}
255261
}

0 commit comments

Comments
 (0)