Fix location/range on TypeScript ExportNamedDeclarations (#9406)
This commit is contained in:
@@ -1853,10 +1853,15 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
parseExportDeclaration(node: N.ExportNamedDeclaration): ?N.Declaration {
|
||||
// Store original location/position
|
||||
const startPos = this.state.start;
|
||||
const startLoc = this.state.startLoc;
|
||||
|
||||
// "export declare" is equivalent to just "export".
|
||||
const isDeclare = this.eatContextual("declare");
|
||||
|
||||
let declaration: ?N.Declaration;
|
||||
|
||||
if (this.match(tt.name)) {
|
||||
declaration = this.tsTryParseExportDeclaration();
|
||||
}
|
||||
@@ -1865,6 +1870,9 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
||||
}
|
||||
|
||||
if (declaration && isDeclare) {
|
||||
// Reset location to include `declare` in range
|
||||
this.resetStartLocation(declaration, startPos, startLoc);
|
||||
|
||||
declaration.declare = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user