TS: Expose optional parameters at syntax level

This commit is contained in:
Asger F
2019-11-16 08:38:44 +00:00
parent b6b8213e13
commit 4a885cbf92
15 changed files with 146 additions and 22 deletions

View File

@@ -0,0 +1,15 @@
| tst.ts:1:23:1:23 | y |
| tst.ts:2:16:2:16 | y |
| tst.ts:6:28:6:28 | y |
| tst.ts:8:12:8:12 | x |
| tst.ts:8:24:8:24 | y |
| tst.ts:9:13:9:13 | x |
| tst.ts:13:7:13:7 | x |
| tst.ts:14:13:14:13 | x |
| tst.ts:15:17:15:17 | y |
| tst.ts:18:26:18:26 | y |
| tst.ts:18:30:18:30 | z |
| tst.ts:18:34:18:34 | w |
| tst.ts:20:40:20:45 | {x, y} |
| tst.ts:20:49:20:51 | [w] |
| withDefault.ts:1:22:1:22 | x |

View File

@@ -0,0 +1,3 @@
import javascript
query Parameter optionalParams() { result.isDeclaredOptional() }

View File

@@ -0,0 +1,20 @@
function f(x: number, y?: string) {
return (x, y?) => {};
}
class C {
constructor(x: number, y?: string) {}
method(x?: number, y?: string) {}
noTypes(x?) {}
}
interface I {
m(x?: number);
field: (x?: number) => void;
(x: number, y?: string): void;
}
function manyDefaults(x, y?, z?, w?) {}
declare function optionalDestructuring({x, y}?, [w]?);

View File

@@ -0,0 +1 @@
function withDefault(x? = 5) {} // not valid syntax