swc/crates/swc_ecma_parser/tests/tsc/optionalProperties01.json
2022-03-22 07:54:08 +00:00

373 lines
9.3 KiB
JSON

{
"type": "Script",
"span": {
"start": 50,
"end": 236,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 50,
"end": 130,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 60,
"end": 63,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 64,
"end": 130,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 68,
"end": 86,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 68,
"end": 77,
"ctxt": 0
},
"value": "required1",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 77,
"end": 85,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 79,
"end": 85,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 89,
"end": 107,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 89,
"end": 98,
"ctxt": 0
},
"value": "required2",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 98,
"end": 106,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 100,
"end": 106,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 110,
"end": 128,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 110,
"end": 118,
"ctxt": 0
},
"value": "optional",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 119,
"end": 127,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 121,
"end": 127,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 132,
"end": 175,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 138,
"end": 174,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 138,
"end": 142,
"ctxt": 0
},
"value": "foo1",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "TsAsExpression",
"span": {
"start": 145,
"end": 174,
"ctxt": 0
},
"expression": {
"type": "ObjectExpression",
"span": {
"start": 145,
"end": 167,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 147,
"end": 156,
"ctxt": 0
},
"value": "required1",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 158,
"end": 165,
"ctxt": 0
},
"value": "hello",
"raw": "\"hello\""
}
}
]
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 171,
"end": 174,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 171,
"end": 174,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"typeParams": null
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 176,
"end": 236,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 182,
"end": 235,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 182,
"end": 186,
"ctxt": 0
},
"value": "foo2",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "TsAsExpression",
"span": {
"start": 189,
"end": 235,
"ctxt": 0
},
"expression": {
"type": "ObjectExpression",
"span": {
"start": 189,
"end": 228,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 191,
"end": 200,
"ctxt": 0
},
"value": "required1",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 202,
"end": 209,
"ctxt": 0
},
"value": "hello",
"raw": "\"hello\""
}
},
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 211,
"end": 219,
"ctxt": 0
},
"value": "optional",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 221,
"end": 226,
"ctxt": 0
},
"value": "bar",
"raw": "\"bar\""
}
}
]
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 232,
"end": 235,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 232,
"end": 235,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"typeParams": null
}
},
"definite": false
}
]
}
],
"interpreter": null
}