Files
Donny/강동윤andGitHub 1e7be03473 fix(es/parser): parse empty Flow exact object type (#11836)
**Description:**

Fixes Flow parsing for empty exact object types like `{||}` by handling
the lexer-produced `||` token only in Flow object type parsing. This
keeps regular logical-or tokenization unchanged and lets React
Native-style type positions parse correctly.

Added fixture coverage for:
- `type X = {||};`
- `React.ComponentType<{||}>`
- `function f(x: {||}): void {}`

**Related issue:**

Fixes #11834
2026-05-02 10:32:32 +09:00

321 lines
7.4 KiB
JSON

{
"type": "Script",
"span": {
"start": 1,
"end": 126
},
"body": [
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 1,
"end": 15
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 6,
"end": 7
},
"ctxt": 0,
"value": "X",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 10,
"end": 14
},
"members": []
}
},
{
"type": "VariableDeclaration",
"span": {
"start": 16,
"end": 58
},
"ctxt": 0,
"kind": "const",
"declare": false,
"declarations": [
{
"type": "VariableDeclarator",
"span": {
"start": 22,
"end": 57
},
"id": {
"type": "Identifier",
"span": {
"start": 22,
"end": 23
},
"ctxt": 0,
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 23,
"end": 50
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 25,
"end": 50
},
"typeName": {
"type": "TsQualifiedName",
"span": {
"start": 25,
"end": 44
},
"left": {
"type": "Identifier",
"span": {
"start": 25,
"end": 30
},
"ctxt": 0,
"value": "React",
"optional": false
},
"right": {
"type": "Identifier",
"span": {
"start": 31,
"end": 44
},
"value": "ComponentType"
}
},
"typeParams": {
"type": "TsTypeParameterInstantiation",
"span": {
"start": 44,
"end": 50
},
"params": [
{
"type": "TsTypeLiteral",
"span": {
"start": 45,
"end": 49
},
"members": []
}
]
}
}
}
},
"init": {
"type": "NullLiteral",
"span": {
"start": 53,
"end": 57
}
},
"definite": false
}
]
},
{
"type": "FunctionDeclaration",
"identifier": {
"type": "Identifier",
"span": {
"start": 68,
"end": 69
},
"ctxt": 0,
"value": "f",
"optional": false
},
"declare": false,
"params": [
{
"type": "Parameter",
"span": {
"start": 70,
"end": 77
},
"decorators": [],
"pat": {
"type": "Identifier",
"span": {
"start": 70,
"end": 71
},
"ctxt": 0,
"value": "x",
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 71,
"end": 77
},
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 73,
"end": 77
},
"members": []
}
}
}
}
],
"decorators": [],
"span": {
"start": 59,
"end": 87
},
"ctxt": 0,
"body": {
"type": "BlockStatement",
"span": {
"start": 85,
"end": 87
},
"ctxt": 0,
"stmts": []
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": {
"type": "TsTypeAnnotation",
"span": {
"start": 78,
"end": 84
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 80,
"end": 84
},
"kind": "void"
}
}
},
{
"type": "TsTypeAliasDeclaration",
"span": {
"start": 88,
"end": 126
},
"declare": false,
"id": {
"type": "Identifier",
"span": {
"start": 93,
"end": 96
},
"ctxt": 0,
"value": "Box",
"optional": false
},
"typeParams": null,
"typeAnnotation": {
"type": "TsTypeLiteral",
"span": {
"start": 99,
"end": 125
},
"members": [
{
"type": "TsPropertySignature",
"span": {
"start": 102,
"end": 113
},
"readonly": true,
"key": {
"type": "Identifier",
"span": {
"start": 103,
"end": 104
},
"ctxt": 0,
"value": "a",
"optional": false
},
"computed": false,
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 104,
"end": 112
},
"typeAnnotation": {
"type": "TsKeywordType",
"span": {
"start": 106,
"end": 112
},
"kind": "number"
}
}
},
{
"type": "TsPropertySignature",
"span": {
"start": 114,
"end": 122
},
"readonly": false,
"key": {
"type": "Identifier",
"span": {
"start": 114,
"end": 122
},
"ctxt": 0,
"value": "__flow_spread",
"optional": false
},
"computed": false,
"optional": false,
"typeAnnotation": {
"type": "TsTypeAnnotation",
"span": {
"start": 114,
"end": 122
},
"typeAnnotation": {
"type": "TsTypeReference",
"span": {
"start": 117,
"end": 122
},
"typeName": {
"type": "Identifier",
"span": {
"start": 117,
"end": 122
},
"ctxt": 0,
"value": "Other",
"optional": false
},
"typeParams": null
}
}
}
]
}
}
],
"interpreter": null
}