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

297 lines
6.7 KiB
JSON

{
"type": "File",
"start": 0,
"end": 69,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 33
}
},
"program": {
"type": "Program",
"start": 0,
"end": 69,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 2,
"column": 33
}
},
"sourceType": "module",
"body": [
{
"type": "DeclareInterface",
"start": 0,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 1,
"column": 35
}
},
"id": {
"type": "Identifier",
"start": 18,
"end": 19,
"loc": {
"start": {
"line": 1,
"column": 18
},
"end": {
"line": 1,
"column": 19
},
"identifierName": "I"
},
"name": "I"
},
"typeParameters": null,
"extends": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 20,
"end": 35,
"loc": {
"start": {
"line": 1,
"column": 20
},
"end": {
"line": 1,
"column": 35
}
},
"callProperties": [],
"properties": [
{
"type": "ObjectTypeProperty",
"start": 22,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 33
}
},
"key": {
"type": "Identifier",
"start": 22,
"end": 25,
"loc": {
"start": {
"line": 1,
"column": 22
},
"end": {
"line": 1,
"column": 25
},
"identifierName": "foo"
},
"name": "foo"
},
"static": false,
"kind": "init",
"value": {
"type": "StringTypeAnnotation",
"start": 27,
"end": 33,
"loc": {
"start": {
"line": 1,
"column": 27
},
"end": {
"line": 1,
"column": 33
}
}
},
"variance": null,
"optional": false
}
],
"indexers": [],
"exact": false
}
},
{
"type": "DeclareInterface",
"start": 36,
"end": 69,
"loc": {
"start": {
"line": 2,
"column": 0
},
"end": {
"line": 2,
"column": 33
}
},
"id": {
"type": "Identifier",
"start": 54,
"end": 55,
"loc": {
"start": {
"line": 2,
"column": 18
},
"end": {
"line": 2,
"column": 19
},
"identifierName": "I"
},
"name": "I"
},
"typeParameters": {
"type": "TypeParameterDeclaration",
"start": 55,
"end": 58,
"loc": {
"start": {
"line": 2,
"column": 19
},
"end": {
"line": 2,
"column": 22
}
},
"params": [
{
"type": "TypeParameter",
"start": 56,
"end": 57,
"loc": {
"start": {
"line": 2,
"column": 20
},
"end": {
"line": 2,
"column": 21
}
},
"name": "T",
"variance": null
}
]
},
"extends": [],
"mixins": [],
"body": {
"type": "ObjectTypeAnnotation",
"start": 59,
"end": 69,
"loc": {
"start": {
"line": 2,
"column": 23
},
"end": {
"line": 2,
"column": 33
}
},
"callProperties": [],
"properties": [
{
"type": "ObjectTypeProperty",
"start": 61,
"end": 67,
"loc": {
"start": {
"line": 2,
"column": 25
},
"end": {
"line": 2,
"column": 31
}
},
"key": {
"type": "Identifier",
"start": 61,
"end": 64,
"loc": {
"start": {
"line": 2,
"column": 25
},
"end": {
"line": 2,
"column": 28
},
"identifierName": "foo"
},
"name": "foo"
},
"static": false,
"kind": "init",
"value": {
"type": "GenericTypeAnnotation",
"start": 66,
"end": 67,
"loc": {
"start": {
"line": 2,
"column": 30
},
"end": {
"line": 2,
"column": 31
}
},
"typeParameters": null,
"id": {
"type": "Identifier",
"start": 66,
"end": 67,
"loc": {
"start": {
"line": 2,
"column": 30
},
"end": {
"line": 2,
"column": 31
},
"identifierName": "T"
},
"name": "T"
}
},
"variance": null,
"optional": false
}
],
"indexers": [],
"exact": false
}
}
],
"directives": []
}
}