This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/typescript: Add a test for function overloads
- Loading branch information
Tavian Barnes
committed
Oct 1, 2019
1 parent
590cde3
commit 886a5fd
Showing
2 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/** | ||
* An overloaded function (1). | ||
*/ | ||
function foo(bar: number): number; | ||
|
||
/** | ||
* An overloaded function (2). | ||
*/ | ||
function foo(bar: string): string; | ||
|
||
function foo(bar: number | string): number | string { | ||
return bar; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
[ | ||
{ | ||
"comment": "<empty>", | ||
"description": "", | ||
"kind": "external", | ||
"longname": "external:overload", | ||
"meta": { | ||
"code": {}, | ||
"filename": "overload.ts", | ||
"lineno": 1, | ||
"path": "./" | ||
}, | ||
"name": "\"overload\"" | ||
}, | ||
{ | ||
"comment": "<empty>", | ||
"description": "An overloaded function (1).\n\n", | ||
"kind": "function", | ||
"longname": "external:overload.foo", | ||
"memberof": "external:overload", | ||
"meta": { | ||
"code": { | ||
"paramnames": [ | ||
"bar" | ||
] | ||
}, | ||
"filename": "overload.ts", | ||
"lineno": 4, | ||
"path": "./" | ||
}, | ||
"name": "foo", | ||
"params": [ | ||
{ | ||
"description": "", | ||
"name": "bar", | ||
"type": { | ||
"names": [ | ||
"number" | ||
] | ||
} | ||
} | ||
], | ||
"returns": [ | ||
{ | ||
"name": "foo", | ||
"type": { | ||
"names": [ | ||
"number" | ||
] | ||
} | ||
} | ||
] | ||
}, | ||
{ | ||
"comment": "<empty>", | ||
"description": "An overloaded function (2).\n\n", | ||
"kind": "function", | ||
"longname": "external:overload.foo", | ||
"memberof": "external:overload", | ||
"meta": { | ||
"code": { | ||
"paramnames": [ | ||
"bar" | ||
] | ||
}, | ||
"filename": "overload.ts", | ||
"lineno": 4, | ||
"path": "./" | ||
}, | ||
"name": "foo", | ||
"params": [ | ||
{ | ||
"description": "", | ||
"name": "bar", | ||
"type": { | ||
"names": [ | ||
"string" | ||
] | ||
} | ||
} | ||
], | ||
"returns": [ | ||
{ | ||
"name": "foo", | ||
"type": { | ||
"names": [ | ||
"string" | ||
] | ||
} | ||
} | ||
] | ||
} | ||
] |