Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

register import equals specifier #10710

Merged
merged 1 commit into from Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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": []
}
}