Skip to content

Commit

Permalink
register ImportEqualsSpecifier to scope (#10710)
Browse files Browse the repository at this point in the history
Co-authored-by: <jaejoon.choi>
  • Loading branch information
JLHwung committed Nov 18, 2019
1 parent faf1492 commit cfd26fd
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/babel-parser/src/plugins/typescript/index.js
Expand Up @@ -21,6 +21,7 @@ import {
BIND_TS_AMBIENT,
BIND_TS_NAMESPACE,
BIND_CLASS,
BIND_LEXICAL,
} from "../../util/scopeflags";
import TypeScriptScopeHandler from "./scope";
import * as charCodes from "charcodes";
Expand Down Expand Up @@ -1292,6 +1293,12 @@ export default (superClass: Class<Parser>): Class<Parser> =>
): N.TsImportEqualsDeclaration {
node.isExport = isExport || false;
node.id = this.parseIdentifier();
this.checkLVal(
node.id,
BIND_LEXICAL,
undefined,
"import equals declaration",
);
this.expect(tt.eq);
node.moduleReference = this.tsParseModuleReference();
this.semicolon();
Expand Down
@@ -0,0 +1,2 @@
import a = require("a");
export { a };
@@ -0,0 +1,171 @@
{
"type": "File",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 13
}
},
"program": {
"type": "Program",
"start": 0,
"end": 38,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 13
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "TSImportEqualsDeclaration",
"start": 0,
"end": 24,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 24
}
},
"isExport": false,
"id": {
"type": "Identifier",
"start": 7,
"end": 8,
"loc": {
"start": {
"line": 1,
"column": 7
},
"end": {
"line": 1,
"column": 8
},
"identifierName": "a"
},
"name": "a"
},
"moduleReference": {
"type": "TSExternalModuleReference",
"start": 11,
"end": 23,
"loc": {
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 23
}
},
"expression": {
"type": "StringLiteral",
"start": 19,
"end": 22,
"loc": {
"start": {
"line": 1,
"column": 19
},
"end": {
"line": 1,
"column": 22
}
},
"extra": {
"rawValue": "a",
"raw": "\"a\""
},
"value": "a"
}
}
},
{
"type": "ExportNamedDeclaration",
"start": 25,
"end": 38,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 13
}
},
"specifiers": [
{
"type": "ExportSpecifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
}
},
"local": {
"type": "Identifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "a"
},
"name": "a"
},
"exported": {
"type": "Identifier",
"start": 34,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 9
},
"end": {
"line": 2,
"column": 10
},
"identifierName": "a"
},
"name": "a"
}
}
],
"source": null,
"declaration": null
}
],
"directives": []
}
}

0 comments on commit cfd26fd

Please sign in to comment.