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
This commit is contained in:
204
test/fixtures/flow/declare-export/export-interface-commonjs/expected.json
vendored
Normal file
204
test/fixtures/flow/declare-export/export-interface-commonjs/expected.json
vendored
Normal file
@@ -0,0 +1,204 @@
|
||||
{
|
||||
"type": "File",
|
||||
"start": 0,
|
||||
"end": 88,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 88
|
||||
}
|
||||
},
|
||||
"program": {
|
||||
"type": "Program",
|
||||
"start": 0,
|
||||
"end": 88,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 88
|
||||
}
|
||||
},
|
||||
"sourceType": "module",
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareModule",
|
||||
"start": 0,
|
||||
"end": 88,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 88
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "StringLiteral",
|
||||
"start": 15,
|
||||
"end": 20,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 15
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 20
|
||||
}
|
||||
},
|
||||
"extra": {
|
||||
"rawValue": "foo",
|
||||
"raw": "\"foo\""
|
||||
},
|
||||
"value": "foo"
|
||||
},
|
||||
"body": {
|
||||
"type": "BlockStatement",
|
||||
"start": 21,
|
||||
"end": 88,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 21
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 88
|
||||
}
|
||||
},
|
||||
"body": [
|
||||
{
|
||||
"type": "DeclareExportDeclaration",
|
||||
"start": 23,
|
||||
"end": 54,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 23
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 54
|
||||
}
|
||||
},
|
||||
"specifiers": [],
|
||||
"source": null,
|
||||
"declaration": {
|
||||
"type": "InterfaceDeclaration",
|
||||
"start": 38,
|
||||
"end": 54,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 38
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 54
|
||||
}
|
||||
},
|
||||
"id": {
|
||||
"type": "Identifier",
|
||||
"start": 48,
|
||||
"end": 51,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 48
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 51
|
||||
},
|
||||
"identifierName": "bar"
|
||||
},
|
||||
"name": "bar"
|
||||
},
|
||||
"typeParameters": null,
|
||||
"extends": [],
|
||||
"mixins": [],
|
||||
"body": {
|
||||
"type": "ObjectTypeAnnotation",
|
||||
"start": 52,
|
||||
"end": 54,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 52
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 54
|
||||
}
|
||||
},
|
||||
"callProperties": [],
|
||||
"properties": [],
|
||||
"indexers": [],
|
||||
"exact": false
|
||||
}
|
||||
},
|
||||
"default": false
|
||||
},
|
||||
{
|
||||
"type": "DeclareModuleExports",
|
||||
"start": 55,
|
||||
"end": 86,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 55
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 86
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "TypeAnnotation",
|
||||
"start": 77,
|
||||
"end": 85,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 77
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 85
|
||||
}
|
||||
},
|
||||
"typeAnnotation": {
|
||||
"type": "NumberTypeAnnotation",
|
||||
"start": 79,
|
||||
"end": 85,
|
||||
"loc": {
|
||||
"start": {
|
||||
"line": 1,
|
||||
"column": 79
|
||||
},
|
||||
"end": {
|
||||
"line": 1,
|
||||
"column": 85
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"kind": "CommonJS"
|
||||
}
|
||||
],
|
||||
"directives": []
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user