Huáng Jùnliàng 461ba2531a
refactor: add parse*Literal parser routines (#13333)
* refactor: simplify parseLiteral interface

* refactor: extract specific methods on parsing literals

* fix: avoid StringLiteral type comparison

* add test cases

* fix: remove redundant node

* Update packages/babel-parser/src/plugins/flow/index.js

Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>

* update test fixtures

* fix: refine parseLiteral typings

Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
2021-05-19 16:00:24 -04:00

51 lines
1.8 KiB
JSON

{
"type": "File",
"start":0,"end":51,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":51}},
"program": {
"type": "Program",
"start":0,"end":51,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":51}},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "ImportDeclaration",
"start":0,"end":51,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":51}},
"specifiers": [
{
"type": "ImportDefaultSpecifier",
"start":7,"end":10,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":10}},
"local": {
"type": "Identifier",
"start":7,"end":10,"loc":{"start":{"line":1,"column":7},"end":{"line":1,"column":10},"identifierName":"foo"},
"name": "foo"
}
}
],
"importKind": "value",
"source": {
"type": "Literal",
"start":16,"end":26,"loc":{"start":{"line":1,"column":16},"end":{"line":1,"column":26}},
"value": "foo.json",
"raw": "\"foo.json\""
},
"assertions": [
{
"type": "ImportAttribute",
"start":36,"end":48,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":48}},
"key": {
"type": "Identifier",
"start":36,"end":40,"loc":{"start":{"line":1,"column":36},"end":{"line":1,"column":40},"identifierName":"type"},
"name": "type"
},
"value": {
"type": "Literal",
"start":42,"end":48,"loc":{"start":{"line":1,"column":42},"end":{"line":1,"column":48}},
"value": "json",
"raw": "\"json\""
}
}
]
}
]
}
}