Skip to content

Commit 4f49ffb

Browse files
committed
Fix JSON Serialization for source
1 parent cd273ad commit 4f49ffb

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/language/ast.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class Location {
3333

3434
constructor(startToken: Token, endToken: Token, source: Source);
3535

36-
toJSON(): { start: number; end: number };
36+
toJSON(): { start: number; end: number; source: Source };
3737
}
3838

3939
/**

src/language/ast.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ export class Location {
4141
this.source = source;
4242
}
4343

44-
toJSON(): {| start: number, end: number |} {
45-
return { start: this.start, end: this.end };
44+
toJSON(): {| start: number, end: number, source: Source |} {
45+
return { start: this.start, end: this.end, source: this.source };
4646
}
4747
}
4848

src/language/source.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ export class Source {
4848
get [SYMBOL_TO_STRING_TAG]() {
4949
return 'Source';
5050
}
51+
52+
toJSON(): {| body: string, name: string |} {
53+
return {
54+
body: this.body,
55+
name: this.name,
56+
};
57+
}
5158
}
5259

5360
/**

0 commit comments

Comments
 (0)