{ "type": "Program", "statements": [ { "type": "TSDeclareFunction", "function": { "type": "ScriptFunction", "id": { "type": "Identifier", "name": "foo", "decorators": [], "loc": { "start": { "line": 17, "column": 10 }, "end": { "line": 17, "column": 13 } } }, "generator": false, "async": false, "expression": false, "params": [ { "type": "Identifier", "name": "a", "typeAnnotation": { "type": "TSNumberKeyword", "loc": { "start": { "line": 17, "column": 17 }, "end": { "line": 17, "column": 23 } } }, "decorators": [], "loc": { "start": { "line": 17, "column": 14 }, "end": { "line": 17, "column": 15 } } }, { "type": "Identifier", "name": "b", "typeAnnotation": { "type": "TSStringKeyword", "loc": { "start": { "line": 17, "column": 29 }, "end": { "line": 17, "column": 35 } } }, "optional": true, "decorators": [], "loc": { "start": { "line": 17, "column": 25 }, "end": { "line": 17, "column": 26 } } } ], "returnType": { "type": "TSNumberKeyword", "loc": { "start": { "line": 17, "column": 38 }, "end": { "line": 17, "column": 44 } } }, "loc": { "start": { "line": 17, "column": 1 }, "end": { "line": 17, "column": 45 } } }, "loc": { "start": { "line": 17, "column": 1 }, "end": { "line": 17, "column": 45 } } }, { "type": "TSDeclareFunction", "function": { "type": "ScriptFunction", "id": { "type": "Identifier", "name": "foo", "decorators": [], "loc": { "start": { "line": 18, "column": 10 }, "end": { "line": 18, "column": 13 } } }, "generator": false, "async": false, "expression": false, "params": [ { "type": "Identifier", "name": "a", "typeAnnotation": { "type": "TSUnionType", "types": [ { "type": "TSStringKeyword", "loc": { "start": { "line": 18, "column": 17 }, "end": { "line": 18, "column": 23 } } }, { "type": "TSNumberKeyword", "loc": { "start": { "line": 18, "column": 26 }, "end": { "line": 18, "column": 32 } } } ], "loc": { "start": { "line": 18, "column": 17 }, "end": { "line": 18, "column": 32 } } }, "decorators": [], "loc": { "start": { "line": 18, "column": 14 }, "end": { "line": 18, "column": 15 } } }, { "type": "Identifier", "name": "b", "typeAnnotation": { "type": "TSStringKeyword", "loc": { "start": { "line": 18, "column": 37 }, "end": { "line": 18, "column": 43 } } }, "decorators": [], "loc": { "start": { "line": 18, "column": 34 }, "end": { "line": 18, "column": 35 } } }, { "type": "Identifier", "name": "c", "typeAnnotation": { "type": "TSNumberKeyword", "loc": { "start": { "line": 18, "column": 48 }, "end": { "line": 18, "column": 54 } } }, "decorators": [], "loc": { "start": { "line": 18, "column": 45 }, "end": { "line": 18, "column": 46 } } } ], "returnType": { "type": "TSNumberKeyword", "loc": { "start": { "line": 18, "column": 57 }, "end": { "line": 18, "column": 63 } } }, "loc": { "start": { "line": 18, "column": 1 }, "end": { "line": 18, "column": 64 } } }, "loc": { "start": { "line": 18, "column": 1 }, "end": { "line": 18, "column": 64 } } }, { "type": "FunctionDeclaration", "function": { "type": "ScriptFunction", "id": { "type": "Identifier", "name": "foo", "decorators": [], "loc": { "start": { "line": 19, "column": 10 }, "end": { "line": 19, "column": 13 } } }, "generator": false, "async": false, "expression": false, "params": [ { "type": "Identifier", "name": "a", "typeAnnotation": { "type": "TSUnionType", "types": [ { "type": "TSStringKeyword", "loc": { "start": { "line": 19, "column": 17 }, "end": { "line": 19, "column": 23 } } }, { "type": "TSNumberKeyword", "loc": { "start": { "line": 19, "column": 26 }, "end": { "line": 19, "column": 32 } } } ], "loc": { "start": { "line": 19, "column": 17 }, "end": { "line": 19, "column": 32 } } }, "decorators": [], "loc": { "start": { "line": 19, "column": 14 }, "end": { "line": 19, "column": 15 } } }, { "type": "Identifier", "name": "b", "typeAnnotation": { "type": "TSStringKeyword", "loc": { "start": { "line": 19, "column": 38 }, "end": { "line": 19, "column": 44 } } }, "optional": true, "decorators": [], "loc": { "start": { "line": 19, "column": 34 }, "end": { "line": 19, "column": 35 } } }, { "type": "Identifier", "name": "c", "typeAnnotation": { "type": "TSNumberKeyword", "loc": { "start": { "line": 19, "column": 50 }, "end": { "line": 19, "column": 56 } } }, "optional": true, "decorators": [], "loc": { "start": { "line": 19, "column": 46 }, "end": { "line": 19, "column": 47 } } } ], "body": { "type": "BlockStatement", "statements": [ { "type": "ReturnStatement", "argument": { "type": "NumberLiteral", "value": 12, "loc": { "start": { "line": 20, "column": 12 }, "end": { "line": 20, "column": 14 } } }, "loc": { "start": { "line": 20, "column": 5 }, "end": { "line": 20, "column": 15 } } } ], "loc": { "start": { "line": 19, "column": 58 }, "end": { "line": 21, "column": 2 } } }, "loc": { "start": { "line": 19, "column": 1 }, "end": { "line": 21, "column": 2 } } }, "loc": { "start": { "line": 19, "column": 1 }, "end": { "line": 21, "column": 2 } } }, { "type": "VariableDeclaration", "declarations": [ { "type": "VariableDeclarator", "id": { "type": "Identifier", "name": "a", "typeAnnotation": { "type": "TSStringKeyword", "loc": { "start": { "line": 23, "column": 8 }, "end": { "line": 23, "column": 14 } } }, "decorators": [], "loc": { "start": { "line": 23, "column": 5 }, "end": { "line": 23, "column": 6 } } }, "init": { "type": "CallExpression", "callee": { "type": "Identifier", "name": "foo", "decorators": [], "loc": { "start": { "line": 23, "column": 17 }, "end": { "line": 23, "column": 20 } } }, "arguments": [ { "type": "NumberLiteral", "value": 2, "loc": { "start": { "line": 23, "column": 21 }, "end": { "line": 23, "column": 22 } } } ], "optional": false, "loc": { "start": { "line": 23, "column": 17 }, "end": { "line": 23, "column": 23 } } }, "loc": { "start": { "line": 23, "column": 5 }, "end": { "line": 23, "column": 23 } } } ], "kind": "var", "loc": { "start": { "line": 23, "column": 1 }, "end": { "line": 23, "column": 24 } } } ], "loc": { "start": { "line": 1, "column": 1 }, "end": { "line": 23, "column": 24 } } } TypeError: Type 'number' is not assignable to type 'string'. [functionOverload4.ts:23:5]