Allow imports in declare module (#315)
* Allow imports in declare module {}
* Rename bodyElement to bodyNode
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token. Only declares are allowed inside declare module (2:2)"
|
||||
"throws": "Only declares and type imports are allowed inside declare module (2:2)"
|
||||
}
|
||||
|
||||
1
test/fixtures/flow/declare-module/import/actual.js
vendored
Normal file
1
test/fixtures/flow/declare-module/import/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
declare module "M" { import type T from "TM"; }
|
||||
156
test/fixtures/flow/declare-module/import/expected.json
vendored
Normal file
156
test/fixtures/flow/declare-module/import/expected.json
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 47,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 47
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 47,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 47
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareModule",
|
||||
"start": 0,
|
||||
"end": 47,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 47
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "StringLiteral",
|
||||
"start": 15,
|
||||
"end": 18,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 18
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "M",
|
||||
"raw": "\"M\""
|
||||
},
|
||||
"value": "M"
|
||||
},
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 19,
|
||||
"end": 47,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 19
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 47
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "ImportDeclaration",
|
||||
"start": 21,
|
||||
"end": 45,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 45
|
||||
}
|
||||
},
|
||||
"specifiers": [
|
||||
{
|
||||
"type": "ImportDefaultSpecifier",
|
||||
"start": 33,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 33
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 34
|
||||
}
|
||||
},
|
||||
"local": {
|
||||
"type": "Identifier",
|
||||
"start": 33,
|
||||
"end": 34,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 33
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 34
|
||||
},
|
||||
"identifierName": "T"
|
||||
},
|
||||
"name": "T"
|
||||
}
|
||||
}
|
||||
],
|
||||
"importKind": "type",
|
||||
"source": {
|
||||
"type": "StringLiteral",
|
||||
"start": 40,
|
||||
"end": 44,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 40
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 44
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "TM",
|
||||
"raw": "\"TM\""
|
||||
},
|
||||
"value": "TM"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
1
test/fixtures/flow/declare-module/invalid-import/actual.js
vendored
Normal file
1
test/fixtures/flow/declare-module/invalid-import/actual.js
vendored
Normal file
@@ -0,0 +1 @@
|
||||
declare module "M" { import T from "TM"; }
|
||||
3
test/fixtures/flow/declare-module/invalid-import/options.json
vendored
Normal file
3
test/fixtures/flow/declare-module/invalid-import/options.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"throws": "Imports within a `declare module` body must always be `import type` or `import typeof` (1:21)"
|
||||
}
|
||||
Reference in New Issue
Block a user