[parser] Fix scope handling of Flow declared functions (#12735)
This commit is contained in:
2
packages/babel-parser/test/fixtures/flow/scope/declare-function-export/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/scope/declare-function-export/input.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
declare function foo(): void;
|
||||
export { foo };
|
||||
61
packages/babel-parser/test/fixtures/flow/scope/declare-function-export/output.json
vendored
Normal file
61
packages/babel-parser/test/fixtures/flow/scope/declare-function-export/output.json
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":45,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":15}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareFunction",
|
||||
"start":0,"end":29,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":17,"end":28,"loc":{"start":{"line":1,"column":17},"end":{"line":1,"column":28},"identifierName":"foo"},
|
||||
"name": "foo",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":20,"end":28,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":28}},
|
||||
"typeAnnotation": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":20,"end":28,"loc":{"start":{"line":1,"column":20},"end":{"line":1,"column":28}},
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":24,"end":28,"loc":{"start":{"line":1,"column":24},"end":{"line":1,"column":28}}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"predicate": null
|
||||
},
|
||||
{
|
||||
"type": "ExportNamedDeclaration",
|
||||
"start":30,"end":45,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":15}},
|
||||
"specifiers": [
|
||||
{
|
||||
"type": "ExportSpecifier",
|
||||
"start":39,"end":42,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":12}},
|
||||
"local": {
|
||||
"type": "Identifier",
|
||||
"start":39,"end":42,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":12},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
},
|
||||
"exported": {
|
||||
"type": "Identifier",
|
||||
"start":39,"end":42,"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":12},"identifierName":"foo"},
|
||||
"name": "foo"
|
||||
}
|
||||
}
|
||||
],
|
||||
"source": null,
|
||||
"declaration": null,
|
||||
"exportKind": "value"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
2
packages/babel-parser/test/fixtures/flow/scope/dupl-decl-func-declare-func/input.js
vendored
Normal file
2
packages/babel-parser/test/fixtures/flow/scope/dupl-decl-func-declare-func/input.js
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
function A() {}
|
||||
declare function A(): void;
|
||||
59
packages/babel-parser/test/fixtures/flow/scope/dupl-decl-func-declare-func/output.json
vendored
Normal file
59
packages/babel-parser/test/fixtures/flow/scope/dupl-decl-func-declare-func/output.json
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":27}},
|
||||
"errors": [
|
||||
"SyntaxError: Identifier 'A' has already been declared (2:17)"
|
||||
],
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start":0,"end":43,"loc":{"start":{"line":1,"column":0},"end":{"line":2,"column":27}},
|
||||
"sourceType": "module",
|
||||
"interpreter": null,
|
||||
"body": [
|
||||
{
|
||||
"type": "FunctionDeclaration",
|
||||
"start":0,"end":15,"loc":{"start":{"line":1,"column":0},"end":{"line":1,"column":15}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":9,"end":10,"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":10},"identifierName":"A"},
|
||||
"name": "A"
|
||||
},
|
||||
"generator": false,
|
||||
"async": false,
|
||||
"params": [],
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start":13,"end":15,"loc":{"start":{"line":1,"column":13},"end":{"line":1,"column":15}},
|
||||
"body": [],
|
||||
"directives": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "DeclareFunction",
|
||||
"start":16,"end":43,"loc":{"start":{"line":2,"column":0},"end":{"line":2,"column":27}},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start":33,"end":42,"loc":{"start":{"line":2,"column":17},"end":{"line":2,"column":26},"identifierName":"A"},
|
||||
"name": "A",
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start":34,"end":42,"loc":{"start":{"line":2,"column":18},"end":{"line":2,"column":26}},
|
||||
"typeAnnotation": {
|
||||
"type": "FunctionTypeAnnotation",
|
||||
"start":34,"end":42,"loc":{"start":{"line":2,"column":18},"end":{"line":2,"column":26}},
|
||||
"typeParameters": null,
|
||||
"params": [],
|
||||
"rest": null,
|
||||
"returnType": {
|
||||
"type": "VoidTypeAnnotation",
|
||||
"start":38,"end":42,"loc":{"start":{"line":2,"column":22},"end":{"line":2,"column":26}}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"predicate": null
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user