| 1 |
import { |
| 2 |
defineAliasedType, |
| 3 |
arrayOfType, |
| 4 |
assertOneOf, |
| 5 |
assertValueType, |
| 6 |
validate, |
| 7 |
validateArrayOfType, |
| 8 |
validateOptional, |
| 9 |
validateOptionalType, |
| 10 |
validateType, |
| 11 |
} from "./utils"; |
| 12 |
|
| 13 |
const defineType = defineAliasedType("Flow"); |
| 14 |
|
| 15 |
const defineInterfaceishType = ( |
| 16 |
name: "DeclareClass" | "DeclareInterface" | "InterfaceDeclaration", |
| 17 |
) => { |
| 18 |
defineType(name, { |
| 19 |
builder: ["id", "typeParameters", "extends", "body"], |
| 20 |
visitor: [ |
| 21 |
"id", |
| 22 |
"typeParameters", |
| 23 |
"extends", |
| 24 |
"mixins", |
| 25 |
"implements", |
| 26 |
"body", |
| 27 |
], |
| 28 |
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
| 29 |
fields: { |
| 30 |
id: validateType("Identifier"), |
| 31 |
typeParameters: validateOptionalType("TypeParameterDeclaration"), |
| 32 |
extends: validateOptional(arrayOfType("InterfaceExtends")), |
| 33 |
mixins: validateOptional(arrayOfType("InterfaceExtends")), |
| 34 |
implements: validateOptional(arrayOfType("ClassImplements")), |
| 35 |
body: validateType("ObjectTypeAnnotation"), |
| 36 |
}, |
| 37 |
}); |
| 38 |
}; |
| 39 |
|
| 40 |
defineType("AnyTypeAnnotation", { |
| 41 |
aliases: ["FlowType", "FlowBaseAnnotation"], |
| 42 |
}); |
| 43 |
|
| 44 |
defineType("ArrayTypeAnnotation", { |
| 45 |
visitor: ["elementType"], |
| 46 |
aliases: ["FlowType"], |
| 47 |
fields: { |
| 48 |
elementType: validateType("FlowType"), |
| 49 |
}, |
| 50 |
}); |
| 51 |
|
| 52 |
defineType("BooleanTypeAnnotation", { |
| 53 |
aliases: ["FlowType", "FlowBaseAnnotation"], |
| 54 |
}); |
| 55 |
|
| 56 |
defineType("BooleanLiteralTypeAnnotation", { |
| 57 |
builder: ["value"], |
| 58 |
aliases: ["FlowType"], |
| 59 |
fields: { |
| 60 |
value: validate(assertValueType("boolean")), |
| 61 |
}, |
| 62 |
}); |
| 63 |
|
| 64 |
defineType("NullLiteralTypeAnnotation", { |
| 65 |
aliases: ["FlowType", "FlowBaseAnnotation"], |
| 66 |
}); |
| 67 |
|
| 68 |
defineType("ClassImplements", { |
| 69 |
visitor: ["id", "typeParameters"], |
| 70 |
fields: { |
| 71 |
id: validateType("Identifier"), |
| 72 |
typeParameters: validateOptionalType("TypeParameterInstantiation"), |
| 73 |
}, |
| 74 |
}); |
| 75 |
|
| 76 |
defineInterfaceishType("DeclareClass"); |
| 77 |
|
| 78 |
defineType("DeclareFunction", { |
| 79 |
visitor: ["id"], |
| 80 |
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
| 81 |
fields: { |
| 82 |
id: validateType("Identifier"), |
| 83 |
predicate: validateOptionalType("DeclaredPredicate"), |
| 84 |
}, |
| 85 |
}); |
| 86 |
|
| 87 |
defineInterfaceishType("DeclareInterface"); |
| 88 |
|
| 89 |
defineType("DeclareModule", { |
| 90 |
builder: ["id", "body", "kind"], |
| 91 |
visitor: ["id", "body"], |
| 92 |
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
| 93 |
fields: { |
| 94 |
id: validateType(["Identifier", "StringLiteral"]), |
| 95 |
body: validateType("BlockStatement"), |
| 96 |
kind: validateOptional(assertOneOf("CommonJS", "ES")), |
| 97 |
}, |
| 98 |
}); |
| 99 |
|
| 100 |
defineType("DeclareModuleExports", { |
| 101 |
visitor: ["typeAnnotation"], |
| 102 |
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
| 103 |
fields: { |
| 104 |
typeAnnotation: validateType("TypeAnnotation"), |
| 105 |
}, |
| 106 |
}); |
| 107 |
|
| 108 |
defineType("DeclareTypeAlias", { |
| 109 |
visitor: ["id", "typeParameters", "right"], |
| 110 |
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
| 111 |
fields: { |
| 112 |
id: validateType("Identifier"), |
| 113 |
typeParameters: validateOptionalType("TypeParameterDeclaration"), |
| 114 |
right: validateType("FlowType"), |
| 115 |
}, |
| 116 |
}); |
| 117 |
|
| 118 |
defineType("DeclareOpaqueType", { |
| 119 |
visitor: ["id", "typeParameters", "supertype"], |
| 120 |
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
| 121 |
fields: { |
| 122 |
id: validateType("Identifier"), |
| 123 |
typeParameters: validateOptionalType("TypeParameterDeclaration"), |
| 124 |
supertype: validateOptionalType("FlowType"), |
| 125 |
impltype: validateOptionalType("FlowType"), |
| 126 |
}, |
| 127 |
}); |
| 128 |
|
| 129 |
defineType("DeclareVariable", { |
| 130 |
visitor: ["id"], |
| 131 |
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
| 132 |
fields: { |
| 133 |
id: validateType("Identifier"), |
| 134 |
}, |
| 135 |
}); |
| 136 |
|
| 137 |
defineType("DeclareExportDeclaration", { |
| 138 |
visitor: ["declaration", "specifiers", "source"], |
| 139 |
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
| 140 |
fields: { |
| 141 |
declaration: validateOptionalType("Flow"), |
| 142 |
specifiers: validateOptional( |
| 143 |
arrayOfType(["ExportSpecifier", "ExportNamespaceSpecifier"]), |
| 144 |
), |
| 145 |
source: validateOptionalType("StringLiteral"), |
| 146 |
default: validateOptional(assertValueType("boolean")), |
| 147 |
}, |
| 148 |
}); |
| 149 |
|
| 150 |
defineType("DeclareExportAllDeclaration", { |
| 151 |
visitor: ["source"], |
| 152 |
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
| 153 |
fields: { |
| 154 |
source: validateType("StringLiteral"), |
| 155 |
exportKind: validateOptional(assertOneOf("type", "value")), |
| 156 |
}, |
| 157 |
}); |
| 158 |
|
| 159 |
defineType("DeclaredPredicate", { |
| 160 |
visitor: ["value"], |
| 161 |
aliases: ["FlowPredicate"], |
| 162 |
fields: { |
| 163 |
value: validateType("Flow"), |
| 164 |
}, |
| 165 |
}); |
| 166 |
|
| 167 |
defineType("ExistsTypeAnnotation", { |
| 168 |
aliases: ["FlowType"], |
| 169 |
}); |
| 170 |
|
| 171 |
defineType("FunctionTypeAnnotation", { |
| 172 |
visitor: ["typeParameters", "params", "rest", "returnType"], |
| 173 |
aliases: ["FlowType"], |
| 174 |
fields: { |
| 175 |
typeParameters: validateOptionalType("TypeParameterDeclaration"), |
| 176 |
params: validate(arrayOfType("FunctionTypeParam")), |
| 177 |
rest: validateOptionalType("FunctionTypeParam"), |
| 178 |
this: validateOptionalType("FunctionTypeParam"), |
| 179 |
returnType: validateType("FlowType"), |
| 180 |
}, |
| 181 |
}); |
| 182 |
|
| 183 |
defineType("FunctionTypeParam", { |
| 184 |
visitor: ["name", "typeAnnotation"], |
| 185 |
fields: { |
| 186 |
name: validateOptionalType("Identifier"), |
| 187 |
typeAnnotation: validateType("FlowType"), |
| 188 |
optional: validateOptional(assertValueType("boolean")), |
| 189 |
}, |
| 190 |
}); |
| 191 |
|
| 192 |
defineType("GenericTypeAnnotation", { |
| 193 |
visitor: ["id", "typeParameters"], |
| 194 |
aliases: ["FlowType"], |
| 195 |
fields: { |
| 196 |
id: validateType(["Identifier", "QualifiedTypeIdentifier"]), |
| 197 |
typeParameters: validateOptionalType("TypeParameterInstantiation"), |
| 198 |
}, |
| 199 |
}); |
| 200 |
|
| 201 |
defineType("InferredPredicate", { |
| 202 |
aliases: ["FlowPredicate"], |
| 203 |
}); |
| 204 |
|
| 205 |
defineType("InterfaceExtends", { |
| 206 |
visitor: ["id", "typeParameters"], |
| 207 |
fields: { |
| 208 |
id: validateType(["Identifier", "QualifiedTypeIdentifier"]), |
| 209 |
typeParameters: validateOptionalType("TypeParameterInstantiation"), |
| 210 |
}, |
| 211 |
}); |
| 212 |
|
| 213 |
defineInterfaceishType("InterfaceDeclaration"); |
| 214 |
|
| 215 |
defineType("InterfaceTypeAnnotation", { |
| 216 |
visitor: ["extends", "body"], |
| 217 |
aliases: ["FlowType"], |
| 218 |
fields: { |
| 219 |
extends: validateOptional(arrayOfType("InterfaceExtends")), |
| 220 |
body: validateType("ObjectTypeAnnotation"), |
| 221 |
}, |
| 222 |
}); |
| 223 |
|
| 224 |
defineType("IntersectionTypeAnnotation", { |
| 225 |
visitor: ["types"], |
| 226 |
aliases: ["FlowType"], |
| 227 |
fields: { |
| 228 |
types: validate(arrayOfType("FlowType")), |
| 229 |
}, |
| 230 |
}); |
| 231 |
|
| 232 |
defineType("MixedTypeAnnotation", { |
| 233 |
aliases: ["FlowType", "FlowBaseAnnotation"], |
| 234 |
}); |
| 235 |
|
| 236 |
defineType("EmptyTypeAnnotation", { |
| 237 |
aliases: ["FlowType", "FlowBaseAnnotation"], |
| 238 |
}); |
| 239 |
|
| 240 |
defineType("NullableTypeAnnotation", { |
| 241 |
visitor: ["typeAnnotation"], |
| 242 |
aliases: ["FlowType"], |
| 243 |
fields: { |
| 244 |
typeAnnotation: validateType("FlowType"), |
| 245 |
}, |
| 246 |
}); |
| 247 |
|
| 248 |
defineType("NumberLiteralTypeAnnotation", { |
| 249 |
builder: ["value"], |
| 250 |
aliases: ["FlowType"], |
| 251 |
fields: { |
| 252 |
value: validate(assertValueType("number")), |
| 253 |
}, |
| 254 |
}); |
| 255 |
|
| 256 |
defineType("NumberTypeAnnotation", { |
| 257 |
aliases: ["FlowType", "FlowBaseAnnotation"], |
| 258 |
}); |
| 259 |
|
| 260 |
defineType("ObjectTypeAnnotation", { |
| 261 |
visitor: ["properties", "indexers", "callProperties", "internalSlots"], |
| 262 |
aliases: ["FlowType"], |
| 263 |
builder: [ |
| 264 |
"properties", |
| 265 |
"indexers", |
| 266 |
"callProperties", |
| 267 |
"internalSlots", |
| 268 |
"exact", |
| 269 |
], |
| 270 |
fields: { |
| 271 |
properties: validate( |
| 272 |
arrayOfType(["ObjectTypeProperty", "ObjectTypeSpreadProperty"]), |
| 273 |
), |
| 274 |
indexers: { |
| 275 |
validate: arrayOfType("ObjectTypeIndexer"), |
| 276 |
optional: process.env.BABEL_8_BREAKING ? false : true, |
| 277 |
default: [], |
| 278 |
}, |
| 279 |
callProperties: { |
| 280 |
validate: arrayOfType("ObjectTypeCallProperty"), |
| 281 |
optional: process.env.BABEL_8_BREAKING ? false : true, |
| 282 |
default: [], |
| 283 |
}, |
| 284 |
internalSlots: { |
| 285 |
validate: arrayOfType("ObjectTypeInternalSlot"), |
| 286 |
optional: process.env.BABEL_8_BREAKING ? false : true, |
| 287 |
default: [], |
| 288 |
}, |
| 289 |
exact: { |
| 290 |
validate: assertValueType("boolean"), |
| 291 |
default: false, |
| 292 |
}, |
| 293 |
// If the inexact flag is present then this is an object type, and not a |
| 294 |
// declare class, declare interface, or interface. If it is true, the |
| 295 |
// object uses ... to express that it is inexact. |
| 296 |
inexact: validateOptional(assertValueType("boolean")), |
| 297 |
}, |
| 298 |
}); |
| 299 |
|
| 300 |
defineType("ObjectTypeInternalSlot", { |
| 301 |
visitor: ["id", "value", "optional", "static", "method"], |
| 302 |
aliases: ["UserWhitespacable"], |
| 303 |
fields: { |
| 304 |
id: validateType("Identifier"), |
| 305 |
value: validateType("FlowType"), |
| 306 |
optional: validate(assertValueType("boolean")), |
| 307 |
static: validate(assertValueType("boolean")), |
| 308 |
method: validate(assertValueType("boolean")), |
| 309 |
}, |
| 310 |
}); |
| 311 |
|
| 312 |
defineType("ObjectTypeCallProperty", { |
| 313 |
visitor: ["value"], |
| 314 |
aliases: ["UserWhitespacable"], |
| 315 |
fields: { |
| 316 |
value: validateType("FlowType"), |
| 317 |
static: validate(assertValueType("boolean")), |
| 318 |
}, |
| 319 |
}); |
| 320 |
|
| 321 |
defineType("ObjectTypeIndexer", { |
| 322 |
visitor: ["id", "key", "value", "variance"], |
| 323 |
aliases: ["UserWhitespacable"], |
| 324 |
fields: { |
| 325 |
id: validateOptionalType("Identifier"), |
| 326 |
key: validateType("FlowType"), |
| 327 |
value: validateType("FlowType"), |
| 328 |
static: validate(assertValueType("boolean")), |
| 329 |
variance: validateOptionalType("Variance"), |
| 330 |
}, |
| 331 |
}); |
| 332 |
|
| 333 |
defineType("ObjectTypeProperty", { |
| 334 |
visitor: ["key", "value", "variance"], |
| 335 |
aliases: ["UserWhitespacable"], |
| 336 |
fields: { |
| 337 |
key: validateType(["Identifier", "StringLiteral"]), |
| 338 |
value: validateType("FlowType"), |
| 339 |
kind: validate(assertOneOf("init", "get", "set")), |
| 340 |
static: validate(assertValueType("boolean")), |
| 341 |
proto: validate(assertValueType("boolean")), |
| 342 |
optional: validate(assertValueType("boolean")), |
| 343 |
variance: validateOptionalType("Variance"), |
| 344 |
method: validate(assertValueType("boolean")), |
| 345 |
}, |
| 346 |
}); |
| 347 |
|
| 348 |
defineType("ObjectTypeSpreadProperty", { |
| 349 |
visitor: ["argument"], |
| 350 |
aliases: ["UserWhitespacable"], |
| 351 |
fields: { |
| 352 |
argument: validateType("FlowType"), |
| 353 |
}, |
| 354 |
}); |
| 355 |
|
| 356 |
defineType("OpaqueType", { |
| 357 |
visitor: ["id", "typeParameters", "supertype", "impltype"], |
| 358 |
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
| 359 |
fields: { |
| 360 |
id: validateType("Identifier"), |
| 361 |
typeParameters: validateOptionalType("TypeParameterDeclaration"), |
| 362 |
supertype: validateOptionalType("FlowType"), |
| 363 |
impltype: validateType("FlowType"), |
| 364 |
}, |
| 365 |
}); |
| 366 |
|
| 367 |
defineType("QualifiedTypeIdentifier", { |
| 368 |
visitor: ["id", "qualification"], |
| 369 |
fields: { |
| 370 |
id: validateType("Identifier"), |
| 371 |
qualification: validateType(["Identifier", "QualifiedTypeIdentifier"]), |
| 372 |
}, |
| 373 |
}); |
| 374 |
|
| 375 |
defineType("StringLiteralTypeAnnotation", { |
| 376 |
builder: ["value"], |
| 377 |
aliases: ["FlowType"], |
| 378 |
fields: { |
| 379 |
value: validate(assertValueType("string")), |
| 380 |
}, |
| 381 |
}); |
| 382 |
|
| 383 |
defineType("StringTypeAnnotation", { |
| 384 |
aliases: ["FlowType", "FlowBaseAnnotation"], |
| 385 |
}); |
| 386 |
|
| 387 |
defineType("SymbolTypeAnnotation", { |
| 388 |
aliases: ["FlowType", "FlowBaseAnnotation"], |
| 389 |
}); |
| 390 |
|
| 391 |
defineType("ThisTypeAnnotation", { |
| 392 |
aliases: ["FlowType", "FlowBaseAnnotation"], |
| 393 |
}); |
| 394 |
|
| 395 |
defineType("TupleTypeAnnotation", { |
| 396 |
visitor: ["types"], |
| 397 |
aliases: ["FlowType"], |
| 398 |
fields: { |
| 399 |
types: validate(arrayOfType("FlowType")), |
| 400 |
}, |
| 401 |
}); |
| 402 |
|
| 403 |
defineType("TypeofTypeAnnotation", { |
| 404 |
visitor: ["argument"], |
| 405 |
aliases: ["FlowType"], |
| 406 |
fields: { |
| 407 |
argument: validateType("FlowType"), |
| 408 |
}, |
| 409 |
}); |
| 410 |
|
| 411 |
defineType("TypeAlias", { |
| 412 |
visitor: ["id", "typeParameters", "right"], |
| 413 |
aliases: ["FlowDeclaration", "Statement", "Declaration"], |
| 414 |
fields: { |
| 415 |
id: validateType("Identifier"), |
| 416 |
typeParameters: validateOptionalType("TypeParameterDeclaration"), |
| 417 |
right: validateType("FlowType"), |
| 418 |
}, |
| 419 |
}); |
| 420 |
|
| 421 |
defineType("TypeAnnotation", { |
| 422 |
visitor: ["typeAnnotation"], |
| 423 |
fields: { |
| 424 |
typeAnnotation: validateType("FlowType"), |
| 425 |
}, |
| 426 |
}); |
| 427 |
|
| 428 |
defineType("TypeCastExpression", { |
| 429 |
visitor: ["expression", "typeAnnotation"], |
| 430 |
aliases: ["ExpressionWrapper", "Expression"], |
| 431 |
fields: { |
| 432 |
expression: validateType("Expression"), |
| 433 |
typeAnnotation: validateType("TypeAnnotation"), |
| 434 |
}, |
| 435 |
}); |
| 436 |
|
| 437 |
defineType("TypeParameter", { |
| 438 |
visitor: ["bound", "default", "variance"], |
| 439 |
fields: { |
| 440 |
name: validate(assertValueType("string")), |
| 441 |
bound: validateOptionalType("TypeAnnotation"), |
| 442 |
default: validateOptionalType("FlowType"), |
| 443 |
variance: validateOptionalType("Variance"), |
| 444 |
}, |
| 445 |
}); |
| 446 |
|
| 447 |
defineType("TypeParameterDeclaration", { |
| 448 |
visitor: ["params"], |
| 449 |
fields: { |
| 450 |
params: validate(arrayOfType("TypeParameter")), |
| 451 |
}, |
| 452 |
}); |
| 453 |
|
| 454 |
defineType("TypeParameterInstantiation", { |
| 455 |
visitor: ["params"], |
| 456 |
fields: { |
| 457 |
params: validate(arrayOfType("FlowType")), |
| 458 |
}, |
| 459 |
}); |
| 460 |
|
| 461 |
defineType("UnionTypeAnnotation", { |
| 462 |
visitor: ["types"], |
| 463 |
aliases: ["FlowType"], |
| 464 |
fields: { |
| 465 |
types: validate(arrayOfType("FlowType")), |
| 466 |
}, |
| 467 |
}); |
| 468 |
|
| 469 |
defineType("Variance", { |
| 470 |
builder: ["kind"], |
| 471 |
fields: { |
| 472 |
kind: validate(assertOneOf("minus", "plus")), |
| 473 |
}, |
| 474 |
}); |
| 475 |
|
| 476 |
defineType("VoidTypeAnnotation", { |
| 477 |
aliases: ["FlowType", "FlowBaseAnnotation"], |
| 478 |
}); |
| 479 |
|
| 480 |
// Enums |
| 481 |
defineType("EnumDeclaration", { |
| 482 |
aliases: ["Statement", "Declaration"], |
| 483 |
visitor: ["id", "body"], |
| 484 |
fields: { |
| 485 |
id: validateType("Identifier"), |
| 486 |
body: validateType([ |
| 487 |
"EnumBooleanBody", |
| 488 |
"EnumNumberBody", |
| 489 |
"EnumStringBody", |
| 490 |
"EnumSymbolBody", |
| 491 |
]), |
| 492 |
}, |
| 493 |
}); |
| 494 |
|
| 495 |
defineType("EnumBooleanBody", { |
| 496 |
aliases: ["EnumBody"], |
| 497 |
visitor: ["members"], |
| 498 |
fields: { |
| 499 |
explicitType: validate(assertValueType("boolean")), |
| 500 |
members: validateArrayOfType("EnumBooleanMember"), |
| 501 |
hasUnknownMembers: validate(assertValueType("boolean")), |
| 502 |
}, |
| 503 |
}); |
| 504 |
|
| 505 |
defineType("EnumNumberBody", { |
| 506 |
aliases: ["EnumBody"], |
| 507 |
visitor: ["members"], |
| 508 |
fields: { |
| 509 |
explicitType: validate(assertValueType("boolean")), |
| 510 |
members: validateArrayOfType("EnumNumberMember"), |
| 511 |
hasUnknownMembers: validate(assertValueType("boolean")), |
| 512 |
}, |
| 513 |
}); |
| 514 |
|
| 515 |
defineType("EnumStringBody", { |
| 516 |
aliases: ["EnumBody"], |
| 517 |
visitor: ["members"], |
| 518 |
fields: { |
| 519 |
explicitType: validate(assertValueType("boolean")), |
| 520 |
members: validateArrayOfType(["EnumStringMember", "EnumDefaultedMember"]), |
| 521 |
hasUnknownMembers: validate(assertValueType("boolean")), |
| 522 |
}, |
| 523 |
}); |
| 524 |
|
| 525 |
defineType("EnumSymbolBody", { |
| 526 |
aliases: ["EnumBody"], |
| 527 |
visitor: ["members"], |
| 528 |
fields: { |
| 529 |
members: validateArrayOfType("EnumDefaultedMember"), |
| 530 |
hasUnknownMembers: validate(assertValueType("boolean")), |
| 531 |
}, |
| 532 |
}); |
| 533 |
|
| 534 |
defineType("EnumBooleanMember", { |
| 535 |
aliases: ["EnumMember"], |
| 536 |
visitor: ["id"], |
| 537 |
fields: { |
| 538 |
id: validateType("Identifier"), |
| 539 |
init: validateType("BooleanLiteral"), |
| 540 |
}, |
| 541 |
}); |
| 542 |
|
| 543 |
defineType("EnumNumberMember", { |
| 544 |
aliases: ["EnumMember"], |
| 545 |
visitor: ["id", "init"], |
| 546 |
fields: { |
| 547 |
id: validateType("Identifier"), |
| 548 |
init: validateType("NumericLiteral"), |
| 549 |
}, |
| 550 |
}); |
| 551 |
|
| 552 |
defineType("EnumStringMember", { |
| 553 |
aliases: ["EnumMember"], |
| 554 |
visitor: ["id", "init"], |
| 555 |
fields: { |
| 556 |
id: validateType("Identifier"), |
| 557 |
init: validateType("StringLiteral"), |
| 558 |
}, |
| 559 |
}); |
| 560 |
|
| 561 |
defineType("EnumDefaultedMember", { |
| 562 |
aliases: ["EnumMember"], |
| 563 |
visitor: ["id"], |
| 564 |
fields: { |
| 565 |
id: validateType("Identifier"), |
| 566 |
}, |
| 567 |
}); |
| 568 |
|
| 569 |
defineType("IndexedAccessType", { |
| 570 |
visitor: ["objectType", "indexType"], |
| 571 |
aliases: ["FlowType"], |
| 572 |
fields: { |
| 573 |
objectType: validateType("FlowType"), |
| 574 |
indexType: validateType("FlowType"), |
| 575 |
}, |
| 576 |
}); |
| 577 |
|
| 578 |
defineType("OptionalIndexedAccessType", { |
| 579 |
visitor: ["objectType", "indexType"], |
| 580 |
aliases: ["FlowType"], |
| 581 |
fields: { |
| 582 |
objectType: validateType("FlowType"), |
| 583 |
indexType: validateType("FlowType"), |
| 584 |
optional: validate(assertValueType("boolean")), |
| 585 |
}, |
| 586 |
}); |