swc/crates/swc_ecma_parser/tests/tsc/optionalProperties01.json

373 lines
9.3 KiB
JSON
Raw Normal View History

{
"type": "Script",
"span": {
"start": 51,
"end": 237,
"ctxt": 0
},
"body": [
{
"type": "TsInterfaceDeclaration",
"span": {
"start": 51,
"end": 131,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 61,
"end": 64,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"declare": false,
"typeParams": null,
"extends": [],
"body": {
"type": "TsInterfaceBody",
"span": {
"start": 65,
"end": 131,
"ctxt": 0
},
"body": [
{
"type": "TsPropertySignature",
"span": {
"start": 69,
"end": 87,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 69,
"end": 78,
"ctxt": 0
},
"value": "required1",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 78,
"end": 86,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 80,
"end": 86,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 90,
"end": 108,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 90,
"end": 99,
"ctxt": 0
},
"value": "required2",
"optional": false
},
"computed": false,
"optional": false,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 99,
"end": 107,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 101,
"end": 107,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
},
{
"type": "TsPropertySignature",
"span": {
"start": 111,
"end": 129,
"ctxt": 0
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 111,
"end": 119,
"ctxt": 0
},
"value": "optional",
"optional": false
},
"computed": false,
"optional": true,
"init": null,
"params": [],
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 120,
"end": 128,
"ctxt": 0
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 122,
"end": 128,
"ctxt": 0
},
"kind": "string"
}
},
"typeParams": null
}
]
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 133,
"end": 176,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 139,
"end": 175,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 139,
"end": 143,
"ctxt": 0
},
"value": "foo1",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "TsAsExpression",
"span": {
"start": 146,
"end": 175,
"ctxt": 0
},
"expression": {
"type": "ObjectExpression",
"span": {
"start": 146,
"end": 168,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 148,
"end": 157,
"ctxt": 0
},
"value": "required1",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 159,
"end": 166,
"ctxt": 0
},
"value": "hello",
"raw": "\"hello\""
}
}
]
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 172,
"end": 175,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 172,
"end": 175,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"typeParams": null
}
},
"definite": false
}
]
},
{
"type": "VariableDeclaration",
"span": {
"start": 177,
"end": 237,
"ctxt": 0
},
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 183,
"end": 236,
"ctxt": 0
},
"id": {
"type": "Identifier",
"span": {
"start": 183,
"end": 187,
"ctxt": 0
},
"value": "foo2",
"optional": false,
"typeAnnotation": null
},
"init": {
"type": "TsAsExpression",
"span": {
"start": 190,
"end": 236,
"ctxt": 0
},
"expression": {
"type": "ObjectExpression",
"span": {
"start": 190,
"end": 229,
"ctxt": 0
},
"properties": [
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 192,
"end": 201,
"ctxt": 0
},
"value": "required1",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 203,
"end": 210,
"ctxt": 0
},
"value": "hello",
"raw": "\"hello\""
}
},
{
"type": "KeyValueProperty",
"key": {
"type": "Identifier",
"span": {
"start": 212,
"end": 220,
"ctxt": 0
},
"value": "optional",
"optional": false
},
"value": {
"type": "StringLiteral",
"span": {
"start": 222,
"end": 227,
"ctxt": 0
},
"value": "bar",
"raw": "\"bar\""
}
}
]
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 233,
"end": 236,
"ctxt": 0
},
"typeName": {
"type": "Identifier",
"span": {
"start": 233,
"end": 236,
"ctxt": 0
},
"value": "Foo",
"optional": false
},
"typeParams": null
}
},
"definite": false
}
]
}
],
"interpreter": null
}