fix import typeof in declare module (#10132)
This commit is contained in:
parent
31fc1d06bc
commit
1d3f9815df
@ -291,7 +291,7 @@ export default (superClass: Class<Parser>): Class<Parser> =>
|
|||||||
|
|
||||||
if (this.match(tt._import)) {
|
if (this.match(tt._import)) {
|
||||||
this.next();
|
this.next();
|
||||||
if (!this.isContextual("type") && !this.isContextual("typeof")) {
|
if (!this.isContextual("type") && !this.match(tt._typeof)) {
|
||||||
this.unexpected(
|
this.unexpected(
|
||||||
this.state.lastTokStart,
|
this.state.lastTokStart,
|
||||||
"Imports within a `declare module` body must always be `import type` or `import typeof`",
|
"Imports within a `declare module` body must always be `import type` or `import typeof`",
|
||||||
|
|||||||
@ -1 +1,4 @@
|
|||||||
declare module "M" { import type T from "TM"; }
|
declare module "M" {
|
||||||
|
import type T from "TM";
|
||||||
|
import typeof U from "UM";
|
||||||
|
}
|
||||||
|
|||||||
@ -1,29 +1,29 @@
|
|||||||
{
|
{
|
||||||
"type": "File",
|
"type": "File",
|
||||||
"start": 0,
|
"start": 0,
|
||||||
"end": 47,
|
"end": 78,
|
||||||
"loc": {
|
"loc": {
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 0
|
"column": 0
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"line": 1,
|
"line": 4,
|
||||||
"column": 47
|
"column": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"program": {
|
"program": {
|
||||||
"type": "Program",
|
"type": "Program",
|
||||||
"start": 0,
|
"start": 0,
|
||||||
"end": 47,
|
"end": 78,
|
||||||
"loc": {
|
"loc": {
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 0
|
"column": 0
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"line": 1,
|
"line": 4,
|
||||||
"column": 47
|
"column": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
@ -32,15 +32,15 @@
|
|||||||
{
|
{
|
||||||
"type": "DeclareModule",
|
"type": "DeclareModule",
|
||||||
"start": 0,
|
"start": 0,
|
||||||
"end": 47,
|
"end": 78,
|
||||||
"loc": {
|
"loc": {
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 0
|
"column": 0
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"line": 1,
|
"line": 4,
|
||||||
"column": 47
|
"column": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"id": {
|
"id": {
|
||||||
@ -66,59 +66,59 @@
|
|||||||
"body": {
|
"body": {
|
||||||
"type": "BlockStatement",
|
"type": "BlockStatement",
|
||||||
"start": 19,
|
"start": 19,
|
||||||
"end": 47,
|
"end": 78,
|
||||||
"loc": {
|
"loc": {
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 1,
|
||||||
"column": 19
|
"column": 19
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"line": 1,
|
"line": 4,
|
||||||
"column": 47
|
"column": 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"body": [
|
"body": [
|
||||||
{
|
{
|
||||||
"type": "ImportDeclaration",
|
"type": "ImportDeclaration",
|
||||||
"start": 21,
|
"start": 23,
|
||||||
"end": 45,
|
"end": 47,
|
||||||
"loc": {
|
"loc": {
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 2,
|
||||||
"column": 21
|
"column": 2
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"line": 1,
|
"line": 2,
|
||||||
"column": 45
|
"column": 26
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"specifiers": [
|
"specifiers": [
|
||||||
{
|
{
|
||||||
"type": "ImportDefaultSpecifier",
|
"type": "ImportDefaultSpecifier",
|
||||||
"start": 33,
|
"start": 35,
|
||||||
"end": 34,
|
"end": 36,
|
||||||
"loc": {
|
"loc": {
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 2,
|
||||||
"column": 33
|
"column": 14
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"line": 1,
|
"line": 2,
|
||||||
"column": 34
|
"column": 15
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"local": {
|
"local": {
|
||||||
"type": "Identifier",
|
"type": "Identifier",
|
||||||
"start": 33,
|
"start": 35,
|
||||||
"end": 34,
|
"end": 36,
|
||||||
"loc": {
|
"loc": {
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 2,
|
||||||
"column": 33
|
"column": 14
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"line": 1,
|
"line": 2,
|
||||||
"column": 34
|
"column": 15
|
||||||
},
|
},
|
||||||
"identifierName": "T"
|
"identifierName": "T"
|
||||||
},
|
},
|
||||||
@ -129,16 +129,16 @@
|
|||||||
"importKind": "type",
|
"importKind": "type",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "StringLiteral",
|
"type": "StringLiteral",
|
||||||
"start": 40,
|
"start": 42,
|
||||||
"end": 44,
|
"end": 46,
|
||||||
"loc": {
|
"loc": {
|
||||||
"start": {
|
"start": {
|
||||||
"line": 1,
|
"line": 2,
|
||||||
"column": 40
|
"column": 21
|
||||||
},
|
},
|
||||||
"end": {
|
"end": {
|
||||||
"line": 1,
|
"line": 2,
|
||||||
"column": 44
|
"column": 25
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
@ -147,6 +147,76 @@
|
|||||||
},
|
},
|
||||||
"value": "TM"
|
"value": "TM"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ImportDeclaration",
|
||||||
|
"start": 50,
|
||||||
|
"end": 76,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 2
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 28
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"specifiers": [
|
||||||
|
{
|
||||||
|
"type": "ImportDefaultSpecifier",
|
||||||
|
"start": 64,
|
||||||
|
"end": 65,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 16
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 17
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"local": {
|
||||||
|
"type": "Identifier",
|
||||||
|
"start": 64,
|
||||||
|
"end": 65,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 16
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 17
|
||||||
|
},
|
||||||
|
"identifierName": "U"
|
||||||
|
},
|
||||||
|
"name": "U"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"importKind": "typeof",
|
||||||
|
"source": {
|
||||||
|
"type": "StringLiteral",
|
||||||
|
"start": 71,
|
||||||
|
"end": 75,
|
||||||
|
"loc": {
|
||||||
|
"start": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 23
|
||||||
|
},
|
||||||
|
"end": {
|
||||||
|
"line": 3,
|
||||||
|
"column": 27
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"rawValue": "UM",
|
||||||
|
"raw": "\"UM\""
|
||||||
|
},
|
||||||
|
"value": "UM"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user