Correctly parse interface methods named 'static' (#8374)

This commit is contained in:
Kevin Gibbons
2018-07-24 00:25:55 -07:00
committed by Nicolò Ribaudo
parent c70a32ab9d
commit a811cf78e1
7 changed files with 390 additions and 85 deletions

View File

@@ -1,5 +1,4 @@
interface IFoo {
x: boolean;
static (): void;
static y: boolean;
}

View File

@@ -1,28 +1,28 @@
{
"type": "File",
"start": 0,
"end": 72,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"line": 4,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 72,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"line": 4,
"column": 1
}
},
@@ -32,14 +32,14 @@
{
"type": "InterfaceDeclaration",
"start": 0,
"end": 72,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 5,
"line": 4,
"column": 1
}
},
@@ -67,68 +67,18 @@
"body": {
"type": "ObjectTypeAnnotation",
"start": 15,
"end": 72,
"end": 51,
"loc": {
"start": {
"line": 1,
"column": 15
},
"end": {
"line": 5,
"line": 4,
"column": 1
}
},
"callProperties": [
{
"type": "ObjectTypeCallProperty",
"start": 33,
"end": 48,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 17
}
},
"static": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 40,
"end": 48,
"loc": {
"start": {
"line": 3,
"column": 9
},
"end": {
"line": 3,
"column": 17
}
},
"params": [],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "VoidTypeAnnotation",
"start": 44,
"end": 48,
"loc": {
"start": {
"line": 3,
"column": 13
},
"end": {
"line": 3,
"column": 17
}
}
}
}
}
],
"callProperties": [],
"properties": [
{
"type": "ObjectTypeProperty",
@@ -185,55 +135,72 @@
},
{
"type": "ObjectTypeProperty",
"start": 52,
"end": 69,
"start": 33,
"end": 48,
"loc": {
"start": {
"line": 4,
"line": 3,
"column": 2
},
"end": {
"line": 4,
"column": 19
"line": 3,
"column": 17
}
},
"key": {
"type": "Identifier",
"start": 59,
"end": 60,
"start": 33,
"end": 39,
"loc": {
"start": {
"line": 4,
"column": 9
"line": 3,
"column": 2
},
"end": {
"line": 4,
"column": 10
"line": 3,
"column": 8
},
"identifierName": "y"
"identifierName": "static"
},
"name": "y"
"name": "static"
},
"static": true,
"static": false,
"proto": false,
"kind": "init",
"method": false,
"method": true,
"value": {
"type": "BooleanTypeAnnotation",
"start": 62,
"end": 69,
"type": "FunctionTypeAnnotation",
"start": 33,
"end": 48,
"loc": {
"start": {
"line": 4,
"column": 12
"line": 3,
"column": 2
},
"end": {
"line": 4,
"column": 19
"line": 3,
"column": 17
}
},
"params": [],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "VoidTypeAnnotation",
"start": 44,
"end": 48,
"loc": {
"start": {
"line": 3,
"column": 13
},
"end": {
"line": 3,
"column": 17
}
}
}
},
"variance": null,
"optional": false
}
],

View File

@@ -0,0 +1 @@
interface A { static(): number }

View File

@@ -0,0 +1,162 @@
{
"type": "File",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"program": {
"type": "Program",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"sourceType": "module",
"interpreter": null,
"body": [
{
"type": "InterfaceDeclaration",
"start": 0,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 32
}
},
"id": {
"type": "Identifier",
"start": 10,
"end": 11,
"loc": {
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 11
},
"identifierName": "A"
},
"name": "A"
},
"typeParameters": null,
"extends": [],
"implements": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 12,
"end": 32,
"loc": {
"start": {
"line": 1,
"column": 12
},
"end": {
"line": 1,
"column": 32
}
},
"callProperties": [],
"properties": [
{
"type": "ObjectTypeProperty",
"start": 14,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 30
}
},
"key": {
"type": "Identifier",
"start": 14,
"end": 20,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 20
},
"identifierName": "static"
},
"name": "static"
},
"static": false,
"proto": false,
"kind": "init",
"method": true,
"value": {
"type": "FunctionTypeAnnotation",
"start": 14,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 30
}
},
"params": [],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "NumberTypeAnnotation",
"start": 24,
"end": 30,
"loc": {
"start": {
"line": 1,
"column": 24
},
"end": {
"line": 1,
"column": 30
}
}
}
},
"optional": false
}
],
"indexers": [],
"internalSlots": [],
"exact": false
}
}
],
"directives": []
}
}