Daniel Tschinder d1a5220b89 Add support for declare export + fixes (#224)
* Add support for declare export

* Do not allow declare module inside declare module

* Reallow module exports outside module

* Add handling of `declare export default`

Add check for multiple module.export declarations

* Disallow export let/const/type

Refactor parsing object properties to share more code and add support
for getters and setters

* Rename tests

* Update test fixtures

* Optimize for performance

* disallow declare export interface outside of module

* Refactor code to be more readable and less lookahead

* Add comments

* Add test for export star as

* Test for number literal getter/setter

* Add more tests

* Fix tests

* Allow union types and correctly eat semi after type

* Use non computed keys

* Fix tests
2017-04-21 14:41:59 +02:00

656 lines
18 KiB
JSON

{
"type": "File",
"start": 0,
"end": 158,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 8,
"column": 1
}
},
"program": {
"type": "Program",
"start": 0,
"end": 158,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 8,
"column": 1
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareClass",
"start": 0,
"end": 158,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 8,
"column": 1
}
},
"id": {
"type": "Identifier",
"start": 14,
"end": 15,
"loc": {
"start": {
"line": 1,
"column": 14
},
"end": {
"line": 1,
"column": 15
},
"identifierName": "B"
},
"name": "B"
},
"typeParameters": null,
"extends": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 16,
"end": 158,
"loc": {
"start": {
"line": 1,
"column": 16
},
"end": {
"line": 8,
"column": 1
}
},
"callProperties": [],
"properties": [
{
"type": "ObjectTypeProperty",
"start": 20,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 17
}
},
"key": {
"type": "Identifier",
"start": 24,
"end": 25,
"loc": {
"start": {
"line": 2,
"column": 6
},
"end": {
"line": 2,
"column": 7
},
"identifierName": "a"
},
"name": "a"
},
"static": false,
"kind": "get",
"value": {
"type": "FunctionTypeAnnotation",
"start": 20,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 2
},
"end": {
"line": 2,
"column": 17
}
},
"params": [],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "NumberTypeAnnotation",
"start": 29,
"end": 35,
"loc": {
"start": {
"line": 2,
"column": 11
},
"end": {
"line": 2,
"column": 17
}
}
}
},
"optional": false
},
{
"type": "ObjectTypeProperty",
"start": 39,
"end": 61,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 24
}
},
"key": {
"type": "Identifier",
"start": 43,
"end": 44,
"loc": {
"start": {
"line": 3,
"column": 6
},
"end": {
"line": 3,
"column": 7
},
"identifierName": "b"
},
"name": "b"
},
"static": false,
"kind": "set",
"value": {
"type": "FunctionTypeAnnotation",
"start": 39,
"end": 61,
"loc": {
"start": {
"line": 3,
"column": 2
},
"end": {
"line": 3,
"column": 24
}
},
"params": [
{
"type": "FunctionTypeParam",
"start": 45,
"end": 54,
"loc": {
"start": {
"line": 3,
"column": 8
},
"end": {
"line": 3,
"column": 17
}
},
"name": {
"type": "Identifier",
"start": 45,
"end": 46,
"loc": {
"start": {
"line": 3,
"column": 8
},
"end": {
"line": 3,
"column": 9
},
"identifierName": "a"
},
"name": "a"
},
"optional": false,
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 48,
"end": 54,
"loc": {
"start": {
"line": 3,
"column": 11
},
"end": {
"line": 3,
"column": 17
}
}
}
}
],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "VoidTypeAnnotation",
"start": 57,
"end": 61,
"loc": {
"start": {
"line": 3,
"column": 20
},
"end": {
"line": 3,
"column": 24
}
}
}
},
"optional": false
},
{
"type": "ObjectTypeProperty",
"start": 65,
"end": 82,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 4,
"column": 19
}
},
"key": {
"type": "StringLiteral",
"start": 69,
"end": 72,
"loc": {
"start": {
"line": 4,
"column": 6
},
"end": {
"line": 4,
"column": 9
}
},
"extra": {
"rawValue": "c",
"raw": "\"c\""
},
"value": "c"
},
"static": false,
"kind": "get",
"value": {
"type": "FunctionTypeAnnotation",
"start": 65,
"end": 82,
"loc": {
"start": {
"line": 4,
"column": 2
},
"end": {
"line": 4,
"column": 19
}
},
"params": [],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "NumberTypeAnnotation",
"start": 76,
"end": 82,
"loc": {
"start": {
"line": 4,
"column": 13
},
"end": {
"line": 4,
"column": 19
}
}
}
},
"optional": false
},
{
"type": "ObjectTypeProperty",
"start": 86,
"end": 110,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 26
}
},
"key": {
"type": "StringLiteral",
"start": 90,
"end": 93,
"loc": {
"start": {
"line": 5,
"column": 6
},
"end": {
"line": 5,
"column": 9
}
},
"extra": {
"rawValue": "d",
"raw": "\"d\""
},
"value": "d"
},
"static": false,
"kind": "set",
"value": {
"type": "FunctionTypeAnnotation",
"start": 86,
"end": 110,
"loc": {
"start": {
"line": 5,
"column": 2
},
"end": {
"line": 5,
"column": 26
}
},
"params": [
{
"type": "FunctionTypeParam",
"start": 94,
"end": 103,
"loc": {
"start": {
"line": 5,
"column": 10
},
"end": {
"line": 5,
"column": 19
}
},
"name": {
"type": "Identifier",
"start": 94,
"end": 95,
"loc": {
"start": {
"line": 5,
"column": 10
},
"end": {
"line": 5,
"column": 11
},
"identifierName": "a"
},
"name": "a"
},
"optional": false,
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 97,
"end": 103,
"loc": {
"start": {
"line": 5,
"column": 13
},
"end": {
"line": 5,
"column": 19
}
}
}
}
],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "VoidTypeAnnotation",
"start": 106,
"end": 110,
"loc": {
"start": {
"line": 5,
"column": 22
},
"end": {
"line": 5,
"column": 26
}
}
}
},
"optional": false
},
{
"type": "ObjectTypeProperty",
"start": 114,
"end": 129,
"loc": {
"start": {
"line": 6,
"column": 2
},
"end": {
"line": 6,
"column": 17
}
},
"key": {
"type": "NumericLiteral",
"start": 118,
"end": 119,
"loc": {
"start": {
"line": 6,
"column": 6
},
"end": {
"line": 6,
"column": 7
}
},
"extra": {
"rawValue": 1,
"raw": "1"
},
"value": 1
},
"static": false,
"kind": "get",
"value": {
"type": "FunctionTypeAnnotation",
"start": 114,
"end": 129,
"loc": {
"start": {
"line": 6,
"column": 2
},
"end": {
"line": 6,
"column": 17
}
},
"params": [],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "NumberTypeAnnotation",
"start": 123,
"end": 129,
"loc": {
"start": {
"line": 6,
"column": 11
},
"end": {
"line": 6,
"column": 17
}
}
}
},
"optional": false
},
{
"type": "ObjectTypeProperty",
"start": 133,
"end": 155,
"loc": {
"start": {
"line": 7,
"column": 2
},
"end": {
"line": 7,
"column": 24
}
},
"key": {
"type": "NumericLiteral",
"start": 137,
"end": 138,
"loc": {
"start": {
"line": 7,
"column": 6
},
"end": {
"line": 7,
"column": 7
}
},
"extra": {
"rawValue": 2,
"raw": "2"
},
"value": 2
},
"static": false,
"kind": "set",
"value": {
"type": "FunctionTypeAnnotation",
"start": 133,
"end": 155,
"loc": {
"start": {
"line": 7,
"column": 2
},
"end": {
"line": 7,
"column": 24
}
},
"params": [
{
"type": "FunctionTypeParam",
"start": 139,
"end": 148,
"loc": {
"start": {
"line": 7,
"column": 8
},
"end": {
"line": 7,
"column": 17
}
},
"name": {
"type": "Identifier",
"start": 139,
"end": 140,
"loc": {
"start": {
"line": 7,
"column": 8
},
"end": {
"line": 7,
"column": 9
},
"identifierName": "a"
},
"name": "a"
},
"optional": false,
"typeAnnotation": {
"type": "NumberTypeAnnotation",
"start": 142,
"end": 148,
"loc": {
"start": {
"line": 7,
"column": 11
},
"end": {
"line": 7,
"column": 17
}
}
}
}
],
"rest": null,
"typeParameters": null,
"returnType": {
"type": "VoidTypeAnnotation",
"start": 151,
"end": 155,
"loc": {
"start": {
"line": 7,
"column": 20
},
"end": {
"line": 7,
"column": 24
}
}
}
},
"optional": false
}
],
"indexers": [],
"exact": false
}
}
],
"directives": []
}
}