1{ 2 "type": "Program", 3 "statements": [ 4 { 5 "type": "TSDeclareFunction", 6 "function": { 7 "type": "ScriptFunction", 8 "id": { 9 "type": "Identifier", 10 "name": "foo", 11 "decorators": [], 12 "loc": { 13 "start": { 14 "line": 17, 15 "column": 10 16 }, 17 "end": { 18 "line": 17, 19 "column": 13 20 } 21 } 22 }, 23 "generator": false, 24 "async": false, 25 "expression": false, 26 "params": [ 27 { 28 "type": "Identifier", 29 "name": "a", 30 "typeAnnotation": { 31 "type": "TSNumberKeyword", 32 "loc": { 33 "start": { 34 "line": 17, 35 "column": 17 36 }, 37 "end": { 38 "line": 17, 39 "column": 23 40 } 41 } 42 }, 43 "decorators": [], 44 "loc": { 45 "start": { 46 "line": 17, 47 "column": 14 48 }, 49 "end": { 50 "line": 17, 51 "column": 15 52 } 53 } 54 }, 55 { 56 "type": "Identifier", 57 "name": "b", 58 "typeAnnotation": { 59 "type": "TSStringKeyword", 60 "loc": { 61 "start": { 62 "line": 17, 63 "column": 29 64 }, 65 "end": { 66 "line": 17, 67 "column": 35 68 } 69 } 70 }, 71 "optional": true, 72 "decorators": [], 73 "loc": { 74 "start": { 75 "line": 17, 76 "column": 25 77 }, 78 "end": { 79 "line": 17, 80 "column": 26 81 } 82 } 83 } 84 ], 85 "returnType": { 86 "type": "TSNumberKeyword", 87 "loc": { 88 "start": { 89 "line": 17, 90 "column": 38 91 }, 92 "end": { 93 "line": 17, 94 "column": 44 95 } 96 } 97 }, 98 "loc": { 99 "start": { 100 "line": 17, 101 "column": 1 102 }, 103 "end": { 104 "line": 17, 105 "column": 45 106 } 107 } 108 }, 109 "loc": { 110 "start": { 111 "line": 17, 112 "column": 1 113 }, 114 "end": { 115 "line": 17, 116 "column": 45 117 } 118 } 119 }, 120 { 121 "type": "TSDeclareFunction", 122 "function": { 123 "type": "ScriptFunction", 124 "id": { 125 "type": "Identifier", 126 "name": "foo", 127 "decorators": [], 128 "loc": { 129 "start": { 130 "line": 18, 131 "column": 10 132 }, 133 "end": { 134 "line": 18, 135 "column": 13 136 } 137 } 138 }, 139 "generator": false, 140 "async": false, 141 "expression": false, 142 "params": [ 143 { 144 "type": "Identifier", 145 "name": "a", 146 "typeAnnotation": { 147 "type": "TSUnionType", 148 "types": [ 149 { 150 "type": "TSStringKeyword", 151 "loc": { 152 "start": { 153 "line": 18, 154 "column": 17 155 }, 156 "end": { 157 "line": 18, 158 "column": 23 159 } 160 } 161 }, 162 { 163 "type": "TSNumberKeyword", 164 "loc": { 165 "start": { 166 "line": 18, 167 "column": 26 168 }, 169 "end": { 170 "line": 18, 171 "column": 32 172 } 173 } 174 } 175 ], 176 "loc": { 177 "start": { 178 "line": 18, 179 "column": 17 180 }, 181 "end": { 182 "line": 18, 183 "column": 32 184 } 185 } 186 }, 187 "decorators": [], 188 "loc": { 189 "start": { 190 "line": 18, 191 "column": 14 192 }, 193 "end": { 194 "line": 18, 195 "column": 15 196 } 197 } 198 }, 199 { 200 "type": "Identifier", 201 "name": "b", 202 "typeAnnotation": { 203 "type": "TSStringKeyword", 204 "loc": { 205 "start": { 206 "line": 18, 207 "column": 37 208 }, 209 "end": { 210 "line": 18, 211 "column": 43 212 } 213 } 214 }, 215 "decorators": [], 216 "loc": { 217 "start": { 218 "line": 18, 219 "column": 34 220 }, 221 "end": { 222 "line": 18, 223 "column": 35 224 } 225 } 226 }, 227 { 228 "type": "Identifier", 229 "name": "c", 230 "typeAnnotation": { 231 "type": "TSNumberKeyword", 232 "loc": { 233 "start": { 234 "line": 18, 235 "column": 48 236 }, 237 "end": { 238 "line": 18, 239 "column": 54 240 } 241 } 242 }, 243 "decorators": [], 244 "loc": { 245 "start": { 246 "line": 18, 247 "column": 45 248 }, 249 "end": { 250 "line": 18, 251 "column": 46 252 } 253 } 254 } 255 ], 256 "returnType": { 257 "type": "TSNumberKeyword", 258 "loc": { 259 "start": { 260 "line": 18, 261 "column": 57 262 }, 263 "end": { 264 "line": 18, 265 "column": 63 266 } 267 } 268 }, 269 "loc": { 270 "start": { 271 "line": 18, 272 "column": 1 273 }, 274 "end": { 275 "line": 18, 276 "column": 64 277 } 278 } 279 }, 280 "loc": { 281 "start": { 282 "line": 18, 283 "column": 1 284 }, 285 "end": { 286 "line": 18, 287 "column": 64 288 } 289 } 290 }, 291 { 292 "type": "FunctionDeclaration", 293 "function": { 294 "type": "ScriptFunction", 295 "id": { 296 "type": "Identifier", 297 "name": "foo", 298 "decorators": [], 299 "loc": { 300 "start": { 301 "line": 19, 302 "column": 10 303 }, 304 "end": { 305 "line": 19, 306 "column": 13 307 } 308 } 309 }, 310 "generator": false, 311 "async": false, 312 "expression": false, 313 "params": [ 314 { 315 "type": "Identifier", 316 "name": "a", 317 "typeAnnotation": { 318 "type": "TSUnionType", 319 "types": [ 320 { 321 "type": "TSStringKeyword", 322 "loc": { 323 "start": { 324 "line": 19, 325 "column": 17 326 }, 327 "end": { 328 "line": 19, 329 "column": 23 330 } 331 } 332 }, 333 { 334 "type": "TSNumberKeyword", 335 "loc": { 336 "start": { 337 "line": 19, 338 "column": 26 339 }, 340 "end": { 341 "line": 19, 342 "column": 32 343 } 344 } 345 } 346 ], 347 "loc": { 348 "start": { 349 "line": 19, 350 "column": 17 351 }, 352 "end": { 353 "line": 19, 354 "column": 32 355 } 356 } 357 }, 358 "decorators": [], 359 "loc": { 360 "start": { 361 "line": 19, 362 "column": 14 363 }, 364 "end": { 365 "line": 19, 366 "column": 15 367 } 368 } 369 }, 370 { 371 "type": "Identifier", 372 "name": "b", 373 "typeAnnotation": { 374 "type": "TSStringKeyword", 375 "loc": { 376 "start": { 377 "line": 19, 378 "column": 38 379 }, 380 "end": { 381 "line": 19, 382 "column": 44 383 } 384 } 385 }, 386 "optional": true, 387 "decorators": [], 388 "loc": { 389 "start": { 390 "line": 19, 391 "column": 34 392 }, 393 "end": { 394 "line": 19, 395 "column": 35 396 } 397 } 398 }, 399 { 400 "type": "Identifier", 401 "name": "c", 402 "typeAnnotation": { 403 "type": "TSNumberKeyword", 404 "loc": { 405 "start": { 406 "line": 19, 407 "column": 50 408 }, 409 "end": { 410 "line": 19, 411 "column": 56 412 } 413 } 414 }, 415 "optional": true, 416 "decorators": [], 417 "loc": { 418 "start": { 419 "line": 19, 420 "column": 46 421 }, 422 "end": { 423 "line": 19, 424 "column": 47 425 } 426 } 427 } 428 ], 429 "body": { 430 "type": "BlockStatement", 431 "statements": [ 432 { 433 "type": "ReturnStatement", 434 "argument": { 435 "type": "NumberLiteral", 436 "value": 12, 437 "loc": { 438 "start": { 439 "line": 20, 440 "column": 12 441 }, 442 "end": { 443 "line": 20, 444 "column": 14 445 } 446 } 447 }, 448 "loc": { 449 "start": { 450 "line": 20, 451 "column": 5 452 }, 453 "end": { 454 "line": 20, 455 "column": 15 456 } 457 } 458 } 459 ], 460 "loc": { 461 "start": { 462 "line": 19, 463 "column": 58 464 }, 465 "end": { 466 "line": 21, 467 "column": 2 468 } 469 } 470 }, 471 "loc": { 472 "start": { 473 "line": 19, 474 "column": 1 475 }, 476 "end": { 477 "line": 21, 478 "column": 2 479 } 480 } 481 }, 482 "loc": { 483 "start": { 484 "line": 19, 485 "column": 1 486 }, 487 "end": { 488 "line": 21, 489 "column": 2 490 } 491 } 492 }, 493 { 494 "type": "VariableDeclaration", 495 "declarations": [ 496 { 497 "type": "VariableDeclarator", 498 "id": { 499 "type": "Identifier", 500 "name": "a", 501 "typeAnnotation": { 502 "type": "TSStringKeyword", 503 "loc": { 504 "start": { 505 "line": 23, 506 "column": 8 507 }, 508 "end": { 509 "line": 23, 510 "column": 14 511 } 512 } 513 }, 514 "decorators": [], 515 "loc": { 516 "start": { 517 "line": 23, 518 "column": 5 519 }, 520 "end": { 521 "line": 23, 522 "column": 6 523 } 524 } 525 }, 526 "init": { 527 "type": "CallExpression", 528 "callee": { 529 "type": "Identifier", 530 "name": "foo", 531 "decorators": [], 532 "loc": { 533 "start": { 534 "line": 23, 535 "column": 17 536 }, 537 "end": { 538 "line": 23, 539 "column": 20 540 } 541 } 542 }, 543 "arguments": [ 544 { 545 "type": "NumberLiteral", 546 "value": 2, 547 "loc": { 548 "start": { 549 "line": 23, 550 "column": 21 551 }, 552 "end": { 553 "line": 23, 554 "column": 22 555 } 556 } 557 } 558 ], 559 "optional": false, 560 "loc": { 561 "start": { 562 "line": 23, 563 "column": 17 564 }, 565 "end": { 566 "line": 23, 567 "column": 23 568 } 569 } 570 }, 571 "loc": { 572 "start": { 573 "line": 23, 574 "column": 5 575 }, 576 "end": { 577 "line": 23, 578 "column": 23 579 } 580 } 581 } 582 ], 583 "kind": "var", 584 "loc": { 585 "start": { 586 "line": 23, 587 "column": 1 588 }, 589 "end": { 590 "line": 23, 591 "column": 24 592 } 593 } 594 } 595 ], 596 "loc": { 597 "start": { 598 "line": 1, 599 "column": 1 600 }, 601 "end": { 602 "line": 23, 603 "column": 24 604 } 605 } 606} 607TypeError: Type 'number' is not assignable to type 'string'. [functionOverload4.ts:23:5] 608