Skip to content

Commit bb146ef

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

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ export class Source {
4848
get [SYMBOL_TO_STRING_TAG]() {
4949
return 'Source';
5050
}
51+
52+
toJSON(): {| body: string, name: string, locationOffset: Location |} {
53+
return { body: this.body, name: this.name, locationOffset: this.locationOffset };
54+
}
5155
}
5256

5357
/**

0 commit comments

Comments
 (0)